FileSystemWatcher OnChanged

FileSystemWatcher OnChanged

am 20.01.2008 07:40:25 von 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

RE: FileSystemWatcher OnChanged

am 21.01.2008 18:33:03 von PRSoCo

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.

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#


"D2" wrote:

> 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
>