I have a small vb.net application utilising the FileSystemWatcher hooked up to a UNC path, after an undetermined period of time (< day) events from the watcher are not raised.
Im capturing the file created event and passing the path to a processfile code block:
Private Sub开发者_如何学编程 fsWatch1_Created(ByVal sender As Object, ByVal e AsSystem.IO.FileSystemEventArgs) Handles fsWatch1.Created
'file created in path - process it!
ProcessFile(e.FullPath)
End Sub
To me it sounded like low-level problems with the network (that can't necessarily be fixed) - so a quick google search has yielded this article on CodeGuru: http://www.codeguru.com/csharp/.net/net_general/eventsanddelegates/article.php/c9113 in which the author says that it's caused by intermittent network outages (they can go down more frequently than you think - and we're actually talking about the connection between just two machines here, which can be dropped for loads of reasons) and the watcher can end up getting corrupted.
The author hooks into the Error event, and recreates the watcher whenever it's raised.
Hope this helps.
精彩评论