Home » Developer & Programmer » Forms » File size
File size [message #169329] Wed, 26 April 2006 05:19 Go to next message
Catty
Messages: 64
Registered: April 2006
Location: Poland
Member
Hello everyone!
Is there any way to check size of file in Forms? What I mean...
I have file.txt and I want to dispaly it. But I don't want to display empty file ( 0 KB ) So I want to check size before I display it. Is there any procedure or command to do that?
I'm waiting for some advices. Thank you.
Re: File size [message #169445 is a reply to message #169329] Wed, 26 April 2006 21:19 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
You could do a 'host' command of 'dir filename.ext > tmp.txt' and then read the 'tmp.txt' file and determine if the file has zero length.

David
Re: File size [message #169446 is a reply to message #169445] Wed, 26 April 2006 21:20 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
There may be an API that you could call via 'ora_ffi' and get the details of the file that way.

David
Re: File size [message #169463 is a reply to message #169329] Wed, 26 April 2006 23:56 Go to previous messageGo to next message
Catty
Messages: 64
Registered: April 2006
Location: Poland
Member
Hi
Thank you for advice, but what do you mean: "then read the 'tmp.txt' file and determine if the file has zero length" How can I determine zero lenght? In host command or other? Can you show me please.


Re: File size [message #169465 is a reply to message #169463] Thu, 27 April 2006 00:02 Go to previous messageGo to next message
Catty
Messages: 64
Registered: April 2006
Location: Poland
Member
Or maybe I can do that using Text_IO.File_Type for my file? For exmaple:
declare
	kom varchar2(200);
	in_file text_io.File_Type;
begin
	in_file:=text_io.Fopen('C:\plik.txt','r');
if  text_io.is_open(in_file) then
		kom:='D:\proba_stara\tview C:\plik.txt';
	  host(kom, screen);
	  else
  	message('Plik nie zawiera danych', NO_ACKNOWLEDGE);
  	end if ;
	 end;
exit_form;
Re: File size [message #169474 is a reply to message #169465] Thu, 27 April 2006 01:28 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Have a search for 'host dir text_io' because one way is to do a 'host' command of a 'dir' command to a file and then use 'text_io' to read the file. But if your way gives a testable 'failure' when the file is zero length then that is also a working solution.

David
Re: File size [message #169508 is a reply to message #169329] Thu, 27 April 2006 05:52 Go to previous messageGo to next message
Catty
Messages: 64
Registered: April 2006
Location: Poland
Member
In my case test won't be fail because file is open no matter if it's full or empty. So I can't check that in this way.
Re: File size [message #169934 is a reply to message #169508] Sun, 30 April 2006 20:06 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I was reviewing your question and realised that if the file is on the Application Server you could use the 'utl_file.fgetattr' facility.

David
Previous Topic: Multilingual Support
Next Topic: full screen menu
Goto Forum:
  


Current Time: Fri Sep 20 07:26:29 CDT 2024