Hi,
I need some help regarding filesystemwatcher class.
The main issue concerned here is, when a folder is being monitored and a bulk amount of files is added/copied to that folder, I need to know when the file copy is over. I can take action one that mass of files copied later on.
if "c:\myfolder" is the file monitored and if i dump 10,000 files into it, certain event are raised by the file watcher class. that's fine. But i need to know the end point of bulk copy over.
Any suitable suggestions are appreciated along with code snippet.
Thanks in advance.

FileSystemWatcher[?]
Yousuf Khan
Sid007
An alternative approach is to create a special "semaphore file" with a special suffix at the end of the process. Then you can watch for a file appearing with that suffix, and act when it shows up.
hollander67
water.NotifyFilter = NotifyFilters.LastWrite
When this event fires, attempt to rename the file within a try-catch block. If the rename fails, do nothing, if it succeeds, you are reasonably sure that the file write has completed. However, I found that I needed to add a short delay (500msec ) before attempting the rename - otherwise the rename would still fail occasionally, even when the file write was done.
I don't have control over the processes that are writing files into the directory I want to monitor so this is the only way I found to implement this. Is there a simple, reliable way to test a file to see if it has any write locks on it from other processes FileInfo.MoveTo() seems to be the only thing I've found. Has anyone been able to build a reliable system based on FileSystemWatcher
Tommmy77
For the problem that you have I have done something simular (Two different ways). The first was to have the bulk process transfer the files with an extension of pro (Processing), then once the transfer was complete the tranfer process would rename the files with the ext of cpt (Complete). Once done the file wather would wait for a rename event then do it's thing. The secode was for the transfer process to send an emtpy file with the same file name and the extenstion of .ok, when the file watcher new about the .ok file being created it new that it could start processing the transfered file....
Hope this helps.
Mykre
www.ircomm.net - Managed DirectX Game Programming
Kishanb