Saturday, 12 September 2015

File watcher in vb.net

File watcher in vb.net
choose path and any changes to the drive like creation deletion of files will be recorded

Try it




Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        FolderBrowserDialog1.ShowDialog()
        TextBox1.Text = FolderBrowserDialog1.SelectedPath
        FileSystemWatcher1.Path = TextBox1.Text
        MsgBox("Path to monitor is now set to: " & TextBox1.Text)
    End Sub
    Private Sub FileSystemWatcher1_Renamed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Renamed
        ListBox1.Items.Add("File- " & e.FullPath.ToString & " renamed at: " & System.DateTime.Now)
    End Sub
    Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
        ListBox2.Items.Add("File- " & e.FullPath.ToString & " created at: " & System.DateTime.Now)
    End Sub
    Private Sub FileSystemWatcher1_Deleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Deleted
        ListBox3.Items.Add("File- " & e.FullPath.ToString & " deleted at: " & System.DateTime.Now)
    End Sub
    Private Sub FileSystemWatcher1_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
        ListBox4.Items.Add("File- " & e.FullPath.ToString & " modified at: " & System.DateTime.Now)
    End Sub

End Class

No comments:

Post a Comment