FileSystemWatcher to FileSystemIgnorer

T

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?
 
P

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
 

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