(Mar 15, 2015 06:55 PM)sweetysuckscock Wrote: dude you took the code improved it a little and gave no credits you sir are a skid...
w/e just letting everyone else know what your like is all, least i never HAD to copy a? :D ...
let me help u 🤣 ur code is buggy and will not work did u even test it 😏
Code
Imports System.IO
Public Class Form1
Dim Watchers() As FileSystemWatcher
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GetDrives()
End Sub
Private Sub GetDrives()
Dim Count As Integer = 0
Dim drives() As String = Environment.GetLogicalDrives
ReDim Watchers(drives.Length)
For i = 0 To drives.Length - 1
Dim watcher As New FileSystemWatcher(drives(i))
With watcher
.Path = drives(i)
AddHandler .Changed, AddressOf FileSysWatcher_Changed
AddHandler .Created, AddressOf FileSysWatcher_Created
AddHandler .Deleted, AddressOf FileSysWatcher_Deleted
AddHandler .Disposed, AddressOf FileSysWatcher_Disposed
AddHandler .Error, AddressOf FileSysWatcher_Error
AddHandler .Renamed, AddressOf FileSysWatcher_Renamed
End With
Watchers(i) = watcher
watcher.IncludeSubdirectories = True
watcher.EnableRaisingEvents = True
Next
TextBox1.AppendText("added all locical drives")
End Sub
Private Sub FileSysWatcher_Changed(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)
Debug.Print("Name: {0}, Path: {1}", e.Name, e.FullPath)
TextBox1.Invoke(New MethodInvoker(Sub() TextBox1.AppendText(vbNewLine & String.Format("Name: {0}, Path: {1}", e.Name, e.FullPath))))
End Sub
Private Sub FileSysWatcher_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)
Debug.Print("Name: {0}, Path: {1}", e.Name, e.FullPath)
TextBox1.Invoke(New MethodInvoker(Sub() TextBox1.AppendText(vbNewLine & String.Format("Name: {0}, Path: {1}", e.Name, e.FullPath))))
End Sub
Private Sub FileSysWatcher_Deleted(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs)
Debug.Print("Name: {0}, Path: {1}", e.Name, e.FullPath)
TextBox1.Invoke(New MethodInvoker(Sub() TextBox1.AppendText(vbNewLine & String.Format("Name: {0}, Path: {1}", e.Name, e.FullPath))))
End Sub
Private Sub FileSysWatcher_Disposed(ByVal sender As Object, ByVal e As System.EventArgs)
Debug.Print(e.ToString)
End Sub
Private Sub FileSysWatcher_Error(ByVal sender As Object, ByVal e As System.IO.ErrorEventArgs)
Debug.Print(e.GetException.Message)
End Sub
Private Sub FileSysWatcher_Renamed(ByVal sender As Object, ByVal e As System.IO.RenamedEventArgs)
Debug.Print("Name: {0}, Path: {1}", e.Name, e.FullPath)
TextBox1.Invoke(New MethodInvoker(Sub() TextBox1.AppendText(vbNewLine & String.Format("Name: {0}, Path: {1}", e.Name, e.FullPath))))
End Sub
End Class