this code will check a particular drive or a directory and all the file and subdirectores inside it
this code will check a particular drive or a directory and all the file and subdirectores inside it and the changes made inside it..... it
API Declarations
Inherits System.Windows.Forms.Form
Dim WithEvents watcher As New System.IO.FileSystemWatcher()
Dim b As Byte
Rate this code will check a particular drive or a directory and all the file and subdirectores inside it
(1(1 Vote))
watcher.Path = "d:\saroj"
watcher.Filter = "*.*"
MsgBox(System.Environment.StackTrace.ToString())
watcher.IncludeSubdirectories = True
watcher.NotifyFilter = IO.NotifyFilters.CreationTime Or IO.NotifyFilters.DirectoryName Or IO.NotifyFilters.FileName Or IO.NotifyFilters.LastAccess Or IO.NotifyFilters.LastWrite Or IO.NotifyFilters.Size
watcher.EnableRaisingEvents = True
b = 0
End Sub
Private Sub watcher_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles watcher.Changed
If b = 0 Then
writelog(e.Name, e.ChangeType.ToString & " By : " & System.Environment.UserName)
b = 1
End If
End Sub
Private Function writelog(ByVal strFile As String, ByVal strChange As String) As Boolean
Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter("d:\lk.txt", True)
sw.WriteLine(strFile & " " & strChange)
sw.Close()
End Function
Private Sub watcher_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles watcher.Created
writelog(e.Name, e.ChangeType.ToString)
b = 0
End Sub
Private Sub watcher_Deleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles watcher.Deleted
writelog(e.Name, e.ChangeType.ToString)
b = 0
End Sub
Private Sub watcher_Renamed(ByVal sender As Object, ByVal e As System.IO.RenamedEventArgs) Handles watcher.Renamed
writelog(e.OldName, e.ChangeType.ToString & " to " & e.Name)
b = 0
End Sub
this code will check a particular drive or a directory and all the file and subdirectores inside it Comments
No comments yet — be the first to post one!
Post a Comment