We have several .NET applications that monitor a directory for new files, using FileSystemWatcher. The files are copied from another location, uploaded via FTP, etc. When they come in, the files are processed in one way or another. However, one problem that I have never seen a satisfactory answer for is: for large files, how does one know when the files being monitored are still being written to? Obviously, we need to wait until the files are complete and closed before we begin processing them. The event args in the FileSystemWatcher events do not seem to address this.
We have several .NET applications that monitor a directory for new files, using FileSystemWatcher.
Share
Have you tried getting a write lock on the file? If it’s being written to, that should fail, and you know to leave it alone for a bit…