filesystemwatcher changed vb.net

M

marfi95

Hi all,

I have implemented a filesystemwatcher to notify my app when a specific
file has changed. I have a notifyfilter of LastWrite or Size.
However, just opening the file is triggering this. Is there a way
around this since I only want to know when changes have been made ?

Mark
 
M

marfi95

All I was saying is that just opening the file I am watching is
triggering a change event. Here is the code:

Private Sub SetWatcherData()

watcher.Path = ValidateNetworkFileItemPath

' -- set notification for when the validation file is updated
watcher.NotifyFilter = (NotifyFilters.LastWrite Or
NotifyFilters.Size)
watcher.Filter = ValidateItemFileName

' Add event handlers.
AddHandler watcher.Changed, AddressOf OnSerializedFileChanged

' Begin watching.
watcher.EnableRaisingEvents = True

End Sub

Private Sub OnSerializedFileChanged(ByVal source As Object, ByVal e As
FileSystemEventArgs)
MsgBox(e.ChangeType & " " & e.FullPath & " " & e.Name)
End Sub

By just opening the file specified in the variable
(ValidateItemFileName), the event is getting triggered.
 

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