Hack Forums
[.NET] File System Watcher - All Drives - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] File System Watcher - All Drives (/showthread.php?tid=4732048)

Pages: Pages 1 2


* - Only3 - Mar 15, 2015

really then u blind again ur code not even work 🤦‍♂
i didnt hide anything and with the other threads about it anyone can see that i just post how to do it
anyway i can add credit for the vars if this ur problem 😏


* - CodeAssassin - Mar 15, 2015

(Mar 15, 2015 07:12 PM)Only3 Wrote:  really then u blind again ur code not even work 🤦‍♂
i didnt hide anything and with the other threads about it anyone can see that i just post how to do it
anyway i can add credit for the vars if this ur problem 😏

lol well it worked for me, i did see i forgot to "-1" on the array, but it was defiantly working, No its cool i just think its funny how i help a guy then like 2 people suddenly have an idea to make it also.... lol... I seen yours and a project up straight after from hex


* - Jack_Soff - Mar 15, 2015

Code
Sub FileSysWatcher() Dim Drives = IO.Drivelnfo.GetDrives.Where(Function(d) d.IsReady) Dim Watchers(Drives.Count - 1) As IO.FileSystemWatcher For i = 0 To Drives.Count - 1 Watchers(i) = New IO.FileSystemWatcher(Drives(i).Name) With Watchers(i) .Path = Drives(i).Name .IncludeSubdirectories = True .EnableRaisingEvents = True AddHandler .Changed, AddressOf Watcher_Action AddHandler .Created, AddressOf Watcher_Action AddHandler .Deleted, AddressOf Watcher_Action AddHandler .Renamed, AddressOf Watcher_Renamed AddHandler .Error, AddressOf Watcher_Error End With Next End Sub
Private Sub Watcher_Action(sender As Object, e As IO.FileSystemEventArgs) Console.WriteLine("{0} -> {1}", e.FullPath, e.ChangeType) End Sub
Private Sub Watcher_Renamed(sender As Object, e As IO.RenamedEventArgs) Console.WriteLine("{0} Renamed To {1}", e.OldFullPath, e.FullPath) End Sub
Private Sub Watcher_Error(sender As Object, e As IO.ErrorEventArgs) Console.WriteLine("Error -> " & e.GetException.Message) End Sub



* - CodeAssassin - Mar 15, 2015

(Mar 15, 2015 07:18 PM)Jack_Soff Wrote:  
Code
Sub FileSysWatcher() Dim Drives = IO.Drivelnfo.GetDrives.Where(Function(d) d.IsReady) Dim Watchers(Drives.Count - 1) As IO.FileSystemWatcher For i = 0 To Drives.Count - 1 Watchers(i) = New IO.FileSystemWatcher(Drives(i).Name) With Watchers(i) .Path = Drives(i).Name .IncludeSubdirectories = True .EnableRaisingEvents = True AddHandler .Changed, AddressOf Watcher_Action AddHandler .Created, AddressOf Watcher_Action AddHandler .Deleted, AddressOf Watcher_Action AddHandler .Renamed, AddressOf Watcher_Renamed AddHandler .Error, AddressOf Watcher_Error End With Next End Sub
Private Sub Watcher_Action(sender As Object, e As IO.FileSystemEventArgs) Console.WriteLine("{0} -> {1}", e.FullPath, e.ChangeType) End Sub
Private Sub Watcher_Renamed(sender As Object, e As IO.RenamedEventArgs) Console.WriteLine("{0} Renamed To {1}", e.OldFullPath, e.FullPath) End Sub
Private Sub Watcher_Error(sender As Object, e As IO.ErrorEventArgs) Console.WriteLine("Error -> " & e.GetException.Message) End Sub

Well done for enabling skids... You sir just won the jackass award :D


* - Only3 - Mar 15, 2015

i saw the thread about it (few days ago) and saw ur reply with the others replys
the guy made another thread then i decide to write the way i think is the best of doing it
when i post it as reply not many will see it thats why i make thread