Bahadir Cambel
Bahadir Cambel

Reputation: 422

FileSystemWatcher event trigger problem(s)

It seems like , FileSystemWatcher triggers events more than once. Here is my settings ;

 watcher = new FileSystemWatcher();
 watcher.Path = @"D:\testSpace";
 watcher.InternalBufferSize = 1024*64;
 watcher.Deleted += Triggered;
 watcher.Changed += Triggered;
 watcher.Created += Triggered;
 watcher.Error += ErrorOccured;
 watcher.NotifyFilter = NotifyFilters.LastWrite;
 watcher.IncludeSubdirectories = true;

 watcher.EnableRaisingEvents = true; 

do you guys know any work around for these issues ?

Upvotes: 0

Views: 4378

Answers (1)

Alex K.
Alex K.

Reputation: 175936

FileSystemWatcher:

Common file system operations might raise more than one event. For example, when a file is moved from one directory to another, several OnChanged and some OnCreated and OnDeleted events might be raised. Moving a file is a complex operation that consists of multiple simple operations, therefore raising multiple events. Likewise, some applications (for example, antivirus software) might cause additional file system events that are detected by FileSystemWatcher.

The solution to your 1st issue is described in the link.

Upvotes: 4

Related Questions