![]() |
|
[.NET] Using filesystemWatcher - 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] Using filesystemWatcher (/showthread.php?tid=4728497) |
Using filesystemWatcher - Prototype7434 - Mar 13, 2015 Hello Guys... Code 'class Variables....I was writing some code to watch all the drives in a system..if any of the file is deleted it pop a message and show deleted file path.. The code compiles just fine. But there is some problem with the code ..it not giving expected output. Please somebody help me with editing the code so that it works perfectly... A little explanation will also be very helpful.. Thanks in Advance. * - CodeAssassin - Mar 13, 2015 (Mar 13, 2015 08:21 AM)Prototype7434 Wrote: Hello Guys... Hello never having used this i thought i would give it a look.. All the info you need is here A quick example is to drag a filesystemwatcher onto your form. Then set the path to watch, thats pretty much it tbh. Code...in form1 Code Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadI obviously missed the question, I have read on multiple forums you MUST use a separate filewatcher for each drive, but you can hook up to the same event handlers ie : Code Private Sub FileSystemWatcher1_Renamed(ByVal sender As Object, ByVal e As System.IO.RenamedEventArgs) Handles FileSystemWatcher1.Renamed, FilesystemWatcher2.Renamed, Filesystemwatcher3.renamed* - Prototype7434 - Mar 13, 2015 (Mar 13, 2015 10:06 AM)sweetysuckscock Wrote: Can i use filesystemwatcher with removable drives... if so could u suggest me how to do that.. if not suggest me the best way to monitor all the drives in a system ,including removable drives at the same time.. ThanK You * - CodeAssassin - Mar 13, 2015 (Mar 13, 2015 10:45 AM)Prototype7434 Wrote: Can i use filesystemwatcher with removable drives... Yea I'm pretty sure you could, scan drives, pragmatically define new filesystemwatchers with addhandlers, i'll look into more tho as like i said never used a filesystemwatcher before so am looking it all up now :) The GetDrives() method will pick up any thumb drives etc. Seeing as you still seem lost (multi threads) and i also wanted to check out the filesystemwather class I made this.... in case I have to remind you, you should drag a textbox onto an empty form.... Code Imports System.IOThis is a basic quick example if you can't continue form this point i would suggest going over the basics of the language before you attempt anything else like this... EDIT: WOW lol, This truly shows the amount of shit going on in your pc without your knowledge lol kinda cool :3 * - Prototype7434 - Mar 15, 2015 Quote:The GetDrives() method will pick up any thumb drives etc. Hi.... Thank you very much for the help..Its a great post... I tried your code...it runs successfully ,but still there is a problem...it cant watch removable drives.... And the following lines hard for me to understand..could you explain a little bit for me.. Code For i = 0 To drives.Length - 1Whats this Watchers(i) = watcher for?? drives(i) returns all drives including removable...But drives(i)=Removable drive not working in FileSystem Watcher...?? Once Again Thank You very much for the help..🤝 * - CodeAssassin - Mar 15, 2015 (Mar 15, 2015 06:27 AM)Prototype7434 Wrote: Hi.... Whats this Watchers(i) = watcher for?? : watchers is an array "()" < means array. "(i) = watchers" array(index) = object (in our case filesystemwatcher) drives(i) returns all drives including removable...But drives(i)=Removable drive not working in FileSystem Watcher...?? I have no idea what your doing i tested the code just and it picks up all my thumb drives, so not sure what your doing??? * - Prototype7434 - Mar 15, 2015 Quote: I have no idea what your doing i tested the code just and it picks up all my thumb drives, so not sure what your doing??? I run you code without any edit on my system...But dont know why its not picking up any removable drives... Any idea???? Watchers(i)=watcher-----> I mean whats the purpose of this line ...i tried to run without these line...the program run fine without these lines... Thank You[/quote] * - CodeAssassin - Mar 15, 2015 (Mar 15, 2015 07:33 AM)Prototype7434 Wrote: I run you code without any edit on my system...But dont know why its not picking up any removable drives...[/quote] Do you not see the For loop? I think you really need to go over the basics as your missing really simple stuff here mate. but just so you know so it add the current "watcher(drive letter)" to the array so you could access it later if needed. * - nathan72389 - Mar 15, 2015 (Mar 15, 2015 07:04 AM)sweetysuckscock Wrote: I have no idea what your doing i tested the code just and it picks up all my thumb drives, so not sure what your doing??? I know what he is doing. he is blatantly copy and pasting stuff and hoping to get the result he is looking for. * - SIM-1984933 - Mar 15, 2015 FWD https://hackforums.net/showthread.php?tid=4732349 * - Prototype7434 - Mar 18, 2015 Do you not see the For loop? I think you really need to go over the basics as your missing really simple stuff here mate. but just so you know so it add the current "watcher(drive letter)" to the array so you could access it later if needed. [/quote] Their is no problem with your code...but the culprit here is the Dvd Drive....it will give some problem...all the drives after the dvd drive in Alldrives array wont work... I finally got it fixed...Add try/Catch... ✌ * - Only3 - Mar 18, 2015 no this is not solve the problem i told him that his code buggy and not working https://hackforums.net/showthread.php?tid=4732048 |