Checking size of a file on disk

  • Thread starter Thread starter Junior
  • Start date Start date
J

Junior

Hi -experimenting with FTP/Download of files using Access - i've been able
to get the FTP.exe working but i'm using txtboxes to capture the
filename,username,password, etc.
and it is possible to download an empty file from the FTP server, if
incorrect data is entered in the txt boxes.
I'd like to check the file size to be sure it isn't empty before proceeding
to the next step.
 
Junior said:
Hi -experimenting with FTP/Download of files using Access - i've been
able to get the FTP.exe working but i'm using txtboxes to capture the
filename,username,password, etc.
and it is possible to download an empty file from the FTP server, if
incorrect data is entered in the txt boxes.
I'd like to check the file size to be sure it isn't empty before
proceeding to the next step.

You can use the FileLen function to get the size. See the help file for
details.
 
Dirk - thanks - i tried FileLen(path) - but always returns a zero - i've
used it to evaluate several files of known size
is there a 'trick' to using FileLen or some reference i possible don't have
Access2K, WinXP
 
Junior said:
Dirk - thanks - i tried FileLen(path) - but always returns a zero -
i've used it to evaluate several files of known size
is there a 'trick' to using FileLen or some reference i possible
don't have Access2K, WinXP

Do you mean that it appears to work properly when you use it to check an
existing file, but it always returns 0 in the circumstances in which
you're using it? The most likely cause of that is that the download
process has only begun, not finished, at the time when you call FileLen.
That seems quite likely if you're using the command-line FTP.EXE
utility, since that would not be in any way synchronized with your code.

The most common way to synchronize with a utility of this sort is to
start the utility and then enter a timing loop that repeatedly checks
the target file to see if it has more than 0 bytes, indicating that the
utility has finished. But that's not going to work in your case,
because you'll get a 0-byte target file if the source file isn't there
at all.

I imagine that you could work around this by first downloading the
source directory into a file, checking that file to make sure the file
you want to download exists, and only then downloading the file.
However, working with the command-line utility is cumbersome. You could
get finer control, and avoid the synchronization problem entirely, by
using a different FTP mechanism. For example, you could use Dev
Ashish's Internet Data Transfer Transfer Library:

http://www.mvps.org/access/modules/mdl0037.htm
Modules: Internet Data Transfer Library

And there's another freeware FTP utility called Chilkat FTP -- I don't
have the URL handy, but I'm sure you could find it on the web -- that
others have used with great success.
 
Back
Top