Home All Groups Group Topic Archive Search About

FileSystemWatcher to FileSystemIgnorer

Author
27 Mar 2005 7:04 AM
Terry Olsen
I have a console app that uses FileSystemWatcher to watch for a certain file
to be created, then it reads the data out of the file, inserts it into an
sql database, deletes the file and then resumes watching for it to be
created again.

Every now and then, the FileSystemWatcher stops working (maybe the entire
app, I can't tell).  Anyway, the file gets created, the program doesn't see
it.  I delete the file manually, and re-create it, nothing.  The only fix is
to stop the app and restart it.

I haven't been able to figure out why this might happen.  Anyone have any
ideas?

Author
27 Mar 2005 4:55 PM
Paul
I've had this happen to me before too.  Its not happened for a while though,
maybe I changed code somewhere.
This is my code...

Public WithEvents WatchFolder As FileSystemWatcher

Private Sub FormLoad(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'-----------Some Code Cut---------------
WatchFolder = New FileSystemWatcher
WatchFolder.SynchronizingObject = Me
WatchFolder.Path = textBoxWatchPath.Text
'Add a list of Filter we want to specify. Make sure you use OR for each
Filter as we need to all of these.
WatchFolder.NotifyFilter = IO.NotifyFilters.DirectoryName
WatchFolder.NotifyFilter = WatchFolder.NotifyFilter Or
IO.NotifyFilters.FileName
End Sub


Show quoteHide quote
"Terry Olsen" <tolse***@hotmail.com> wrote in message
news:egFKwspMFHA.2468@tk2msftngp13.phx.gbl...
>I have a console app that uses FileSystemWatcher to watch for a certain
>file to be created, then it reads the data out of the file, inserts it into
>an sql database, deletes the file and then resumes watching for it to be
>created again.
>
> Every now and then, the FileSystemWatcher stops working (maybe the entire
> app, I can't tell).  Anyway, the file gets created, the program doesn't
> see it.  I delete the file manually, and re-create it, nothing.  The only
> fix is to stop the app and restart it.
>
> I haven't been able to figure out why this might happen.  Anyone have any
> ideas?