When watching the file system, there may be so many events get occurred to be handled by filesystemwatcher object.When too many events occur, the FileSystemWatcher throws the Error event. To capture the Error event, follow these steps:
1. Create a new FileSystemWatcher object, specifying the directory in the Path
2. Register for the Error event.
3. Turn on events by setting EnableRaisingEvents to true.
The following code snippet demonstrates this process:
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = @"c:\";
// Register for events
// Start Watching
watcher.EnableRaisingEvents = true;
// Event Handler
static void watcher_Error(object sender,