Hello Andy ,
If you want an event driven aproach go for the file system watcher as this
can give you an event when a change took place in a file
so also when there are 2 changes within a minute you get 2 change events .
Ofcourse you could also just use a timer , read the file in a string
variabel and compare the 2 strings if the 2 strings are not the same the
file has changed
however this wil cost you more CPU / IO cycles
Use the filesystem watcher to get notified when a change on the file took
place , and then reread / process the file
http://msdn.microsoft.com/en-us/libr...emwatcher.aspx
in the link i provided ( also in your previous post ) there is example code
included
in case you missed it
Public Class Watcher
Public Shared Sub Main()
Run()
End Sub
<PermissionSet( SecurityAction. Demand, Name:="FullTrus t")_
Private Shared Sub Run
Dim args() As String = System.Environm ent.GetCommandL ineArgs()
' If a directory is not specified, exit the program.
If args.Length <2 Then
' Display the proper way to call the program.
Console.WriteLi ne("Usage: Watcher.exe (directory)")
Return
End If
' Create a new FileSystemWatch er and set its properties.
Dim watcher As New FileSystemWatch er()
watcher.Path = args(1)
' Watch for changes in LastAccess and LastWrite times, and
' the renaming of files or directories.
watcher.NotifyF ilter = (NotifyFilters. LastAccess Or
NotifyFilters.L astWrite Or NotifyFilters.F ileName Or
NotifyFilters.D irectoryName)
' Only watch text files.
watcher.Filter = "*.txt"
' Add event handlers.
AddHandler watcher.Changed , AddressOf OnChanged
AddHandler watcher.Created , AddressOf OnChanged
AddHandler watcher.Deleted , AddressOf OnChanged
AddHandler watcher.Renamed , AddressOf OnRenamed
' Begin watching.
watcher.EnableR aisingEvents = True
' Wait for the user to quit the program.
Console.WriteLi ne("Press 'q' to quit the sample.")
While Chr(Console.Rea d()) <"q"c
End While
End Sub
' Define the event handlers.
Private Shared Sub OnChanged(sourc e As Object, e As FileSystemEvent Args)
' Specify what is done when a file is changed, created, or deleted.
Console.WriteLi ne("File: " & e.FullPath & " " & e.ChangeType)
End Sub
Private Shared Sub OnRenamed(sourc e As Object, e As RenamedEventArg s)
' Specify what is done when a file is renamed.
Console.WriteLi ne("File: {0} renamed to {1}", e.OldFullPath,
e.FullPath)
End Sub
End Class
Michel Posseth [MCP]
http://www.vbdotnetcoder.com
"Andy B" <a_*****@sbcglo bal.netschreef in bericht
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
What would i use to look for changes in a file every minute?