views:

60

answers:

1

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
+2  A: 

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.

Andras Zoltan
I've implemented similar code so that fsw.error is handled and logged.I'll leave this to run for a while and see how it goes, the FSW is running over a WAN link so its very plausible that this is the cause.- Thanks for your help.
antny