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.
source to share
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.
source to share
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.
source to share