Checking for file update

Hi, i have a txt file....how can i in vb.net 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
jaxrpcAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iboutchkineCommented:
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
iboutchkineCommented:
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
                     

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.