Determine when the uploaded FTP file is ready to be processed with FileSystemWatcher

I want users to be able to upload files via FTP to my site (IIS 7.5). After the file is uploaded, I want to process the file using the FileSystemWatcher. How can I tell when a file has finished uploading to the server? I don't want to process it until the entire download is complete.

+3


source to share


3 answers


There is really no way you can tell when a file has finished downloading. It is even possible that it is loaded first and completed later.



You either need to determine from the contents of the file that it is a complete file, or use some other marker. For example, an empty file signifying completion, meaning the user first uploads file1.dat

and then uploads file1.done

to signal that file1.dat

it can now be processed.

+3


source


If you are using IIS 7.5 and above, you can write an FTP provider that can start the process - this will not use File System Watcher, but it probably provides a better alternative.

Below is an IIS tutorial showing an example (sending an email in this case) that you can adapt to your purposes.



http://learn.iis.net/page.aspx/632/how-to-use-managed-code-c-to-create-an-ftp-provider-that-sends-an-email-when-files- are-uploaded /

+1


source


In fact, you can check the file size every second, and if it doesn't grow for a while, the transfer may be ready.

0


source







All Articles