FileSystemWatcher issue

K

Kiavik

I'm developing a Windows Service which uses the FSW object to monitor
some UNC paths, now I know after reading this article
http://tinyurl.com/ykw7aq that FSW is quite unreliable when monitoring
UNC paths so in my service I've also implemented a Timer that stops and
restarts the FSW and checks for files that the FSW missed because it
wasn't intercepting events.

For testing purposes I've installed the service in my machine to
monitor a local path and set the timer to be triggered every 10
minutes. I left the service running over night and this morning I
checked the log file for the service and found that every once in a
while (at random intervals) the FSW raise an exception:
*System.IO.InternalBufferOverflowException* - Too many changes at once
in directory:C:\Pippo
The weird thing is that the directory hasn't been modified at all
during night so why the buffer overflow excepion? The only thing I can
think about is the reset of the FSW, maybe I do it wrong. To reset it I
set the *EnableRaisingEvents* FSW property to false and then back to
true. Is this the correct way? Or should I Dispose and recreate the
object? Or there is some other method to reset the object?

Thanks
 
M

Michael D. Ober

The default "Service" account doesn't have network access. You need to use
either the "Network Service" account (Windows 2003) or another account that
has sufficient privs.

The unreliability of monitoring network drives is actually related to the
fact that only W2K and later support this capability. Samba doesn't either.

As for your InternalBufferOverflow error, please post your code that
configures the FSW and also how you handle the various events. Because FSW
queues up multiple API level File System Watcher events, it keeps a buffer.
My recommendation for handling this is to increase the internal buffer size,
reset your event handlers (in VB - DeleteHandler/AddHandler), and then scan
the folder for changes.

Mike Ober.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top