FileSystemWatcher events being reported when non should be

G

Glenn

I have just started using the FileSystemWatcher in VB.NET. My first attempt
was to connect to a share, using unc paths, to a server running Win2000.
Everything was working great for about two days. Today, at about 6:30am
pst, the program stopped working. At first I thought it was the program, so
I put in some console.writeline statements to track the progress of the
program. What I found out appears to not be a problem with my program but
rather the server. As soon as my program starts and turns
..EnableRaisingEvents to true, it starts reporting files as being changed
which were in fact not changed. When I cancel the program and restart it,
it starts where it left off. It appears, for some reason, that the server
has queued these messages and is continuing to report the events.

Has anyone had this same problem? Does anyone know what I can do to keep
this from happening, or know why it happened in the first place? My first
thought was that the server drives were restored, but this is not the case.

Any help would be greatly appreciated.

fsw.Path = fPath 'fPath = "\\public1\data\html"
fsw.IncludeSubdirectories = True
fsw.EnableRaisingEvents = True
fsw.NotifyFilter = fsw.NotifyFilter Or NotifyFilters.FileName Or
NotifyFilters.LastWrite Or NotifyFilters.Size

Private Sub fsw_All(ByVal sender As Object, ByVal e As FileSystemEventArgs)
Handles fsw.Created, fsw.Changed, fsw.Deleted
Dim changeType As String = [Enum].GetName(GetType(WatcherChangeTypes),
e.ChangeType)
Try
If changeType.ToLower = "deleted" Then
fl.log(e.FullPath & "||" & changeType & "|" & Now())
Else
If Not CBool(File.GetAttributes(e.FullPath) And FileAttributes.Directory)
Then
fl.log(e.FullPath & "||" & changeType & "|" & Now())
End If
End If
Catch
End Try
End Sub

Private Sub fsw_renamed(ByVal sender As Object, ByVal e As RenamedEventArgs)
Handles fsw.Renamed
'If Not CBool(File.GetAttributes(e.FullPath) And FileAttributes.Directory)
Then
fl.log(e.OldFullPath & "|" & e.FullPath & "|renamed" & "|" & Now())
'End If
End Sub
 
G

Glenn

I found out a bit more information. It turns out that Norton AntiVirus was
performing a scan, but I am not sure if the scan was going on during the
time I noticed the problem. I am still wondering what type of change was
being done by the scan that would cause an event to be reported and what the
event was? Is there something that I can do to ignore those events or know
what process caused the event?
 

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