By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,290 Members | 1,263 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,290 IT Pros & Developers. It's quick & easy.

filesystemwatcher changed vb.net

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<ma*****@yahoo.com> schrieb:
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 ?


Short but complete programs
<URL:http://www.pobox.com/~skeet/csharp/complete.html>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #2

P: n/a
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.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.