Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In filesystemwatcher, what are the expected errors the the error event can raise?

I looked in MSDN and in reflector, but couldn't figure it out usually - i get all this information from the description tags, but in this case - no such luck.

I already figured out with experiments:

  • "access is denied" [Win32Exception, native error code=5] if the watched directory is being deleted
  • "too many changes an once" [InternalBufferOverflowException] if the buffer is overflown.

any more ideas?

like image 866
Nissim Avatar asked Nov 19 '25 23:11

Nissim


1 Answers

There also can be UnauthorizedAccessException, when you do not have rights to access folder or specific file.

Also, do not rely heavily on basic FileSystemWatcher,even without InternalBufferOverflowException it can skip some events and works very,very badly of network directories. You should use combine FileSystemWatcher with some polling-style system, for example, run directory scanning every 30 seconds target directory and compare your current, FileSystemWatcher based files list, with real situation, that way you'll have MOST of actual information in real time and ALL information periodically.

like image 56
Xab3r Avatar answered Nov 21 '25 13:11

Xab3r