Search code examples
.netfile-uploadftpfilesystemwatcher

Determine when an FTP uploaded file is ready for processing using FileSystemWatcher


I want users to be able to upload files via FTP to my site (IIS 7.5). Once the file is uploaded, then I want to process the file using FileSystemWatcher. How can you determine when the file has completed uploading to the server? I don't want to process it before it completes the entire upload.


Solution

  • There is really no inherent way that you can know the file has completed uploading. It is even possible that it is uploaded partially first and completed later.

    You either need to determine from the file contents that it is a complete file or use some other marker. For example an empty file signifying completion, i.e. user first uploads file1.dat and then uploads file1.done to signal that file1.dat can now be processed.