Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hey there I am puzzled as how to go about's monitoring multiple or all hard drives on my computer with filesystem watcher eg. C:\, D:\, E:\ ect..
 
I wish to be able to monitor all drives and their subfolders excluding CD\DVD drives if they are not ready or no disk is inserted.
 
I have found some examples online but it has only been confusing as they are not complete in their explanation about how to detect all hard drives and then to assign the paths to multiple instances of the filesystem watcher so that the entire computer is being monitored and not just one directory at a time.
 

thank you in advance!!
Posted 11-Jan-13 21:29pm
Dale 20121.8K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

To list the drives you can use DriveInfo.GetDrives Method[^]. For each drive you need to check whether it's local or not. For this the DriveInfo has DriveType[^].
 
When looping through the drives you can create a new filesystemwatcher and to store the created instances globally, you could for example use a static class with a list poperty. Something like
 
public static WatchInfo {
   public static List<fileSystemWatcher> Watchers = new List<fileSystemWatcher>();
}
Now when creating the instances, just add them to the list and you can refer them from your program later.
 
Of course you would need also to set proper event handlers for changes in the drives.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 386
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 215
3 Maciej Los 169
4 /\jmot 169
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 12 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100