bir dizinin altlarına inmek
Jul 24,2007 00:00 by mustaYfa


    Inherits System.Windows.Forms.Form
    Dim WithEvents watcher As New System.IO.FileSystemWatcher()
    Dim b As Byte

 

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        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