Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.5k views
in .NET FTP by (200 points)
I've tried searching the forums but haven't had any luck discovering how to do this.

I have a situation where I'm periodically checking a FTP site for the existence of a file. That's the easy part. If the file is large and let's say it can take many minutes to write the entire file, is there a wa built into edtFTPnet PRO to tell if a file has completely been written on the FTP side before trying to download it?

Thanks,
Jeff

4 Answers

0 votes
by (162k points)
No, unless the server is smart enough to not list the file until it is finished writing.

Best solution is to upload the file as filename.tmp, and then rename it to filename.ext when the upload is completed.
0 votes
by (200 points)
No, unless the server is smart enough to not list the file until it is finished writing.

Best solution is to upload the file as filename.tmp, and then rename it to filename.ext when the upload is completed.


Thanks for the reply Bruce but in my post I meant I'm waiting for a file to be created on the FTP server side, not a file I'm uploading. In my case, I'm connecting to a 3rd party data provider who will create a file for me on their side. At times this file can be large so when I check I don't want to try to download a file that they haven't finished writing to on their side. Is there a way to check for this?

Thanks,
Jeff
0 votes
by (162k points)
The 3rd party provider should upload to a temp file and then rename (if they are sensible).

Obviously you don't have any control over this though. However it may be worth contacting them to see if it is possible.

Probably the best you can do is to repeatedly get the size of the file, say every 10 seconds. If the size hasn't changed, assume the file is uploaded. Or if you have a good idea of how big it should be, wait until it has reached at least that size, and then not altered.

This may not work for all servers though, but it's what I'd try
0 votes
by (200 points)
The 3rd party provider should upload to a temp file and then rename (if they are sensible).

Obviously you don't have any control over this though. However it may be worth contacting them to see if it is possible.

Probably the best you can do is to repeatedly get the size of the file, say every 10 seconds. If the size hasn't changed, assume the file is uploaded. Or if you have a good idea of how big it should be, wait until it has reached at least that size, and then not altered.

This may not work for all servers though, but it's what I'd try


I found a way through edtFTPnet/Pro that seems to work. GetFileSize will throw an exception if the file is still being written but the FTPFile collection off the connection object has a property, Size, that's 0 while the file's being written and only takes on a non-zero positive value once the file's done writing and checking Size does not throw an exception.

Thanks,
Jeff

Categories

...