Checking for file update

Hi, i have a txt can i in check whether it has been modified? I think it will be like a function which will check the the txt file every 1 sec and returns a boolean when it has been modified... but are there any built in functions to do that? Please point me to the right direction. thanks
Who is Participating?
Dim selectedFile As String = FilesList.Text
        Dim FI As New FileInfo(Directory.GetCurrentDirectory & "\" & selectedFile)

        lblInfo.Text = "File Name:" & FI.Name & vbCrLf & _
                       "Length:" & FI.Length.ToString & vbCrLf & _
                       "Extension:" & FI.Extension.ToString & vbCrLf & _
                       "Creation Time:" & FI.CreationTime.ToString & vbCrLf & _
                       "Accessed:" & FI.LastAccessTime.ToString
you can read Modified date and time of the file property
TimCotteeHead of Software ServicesCommented:
Hi jaxrpc,

Add this to the declarations section    
        Private watcher As FileSystemWatcher

Then in your form_load
        watcher = New FileSystemWatcher()
        watcher.Path = "c:\Myfoldertowatch"
        watcher.NotifyFilter = (NotifyFilters.LastAccess Or NotifyFilters.LastWrite Or NotifyFilters.FileName Or NotifyFilters.DirectoryName)
        watcher.Filter = "MyFileToWatchFor.txt"
        AddHandler watcher.Changed, AddressOf OnChanged
        watcher.EnableRaisingEvents = True
Then add the event so we can handle when it has changed.
    Private Shared Sub OnChanged(source As Object, e As FileSystemEventArgs)
        Msgbox ("The file has changed")
    End Sub    

Tim Cottee
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.