FileSystemWatcher OnChanged

  • Thread starter Thread starter D2
  • Start date Start date
D

D2

Hi,

I'm using FileSystemWatcher to monitor certain folders in file system.
In some specific scenarios where a large file is copied to the
monitored folder, I receive too many Onchanged events. I'm clueless as
how can i detect the file has finally been copied? any help would be
appreciated.

thanks,
d2
 
You can't know for sure. You can't even know if the two OnChanged events
were the result of the same action or the same application.

The best you can do is timeout after a certain amount of time without
receiving OnChanged. e.g. when you get an OnChanged for a file, set a timer
for 500 ms. If you get another OnChanged event, reset that timer. When the
Elapsed event for the timer is raised, you know nothing has changed the file
in 500ms and whatever action that was being performed might be completed.
 
Back
Top