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 20: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
Your Filters
Interested
Ignored
     
0 Shai Vashdi 600
1 Tadit Dash 305
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 190
4 OriginalGriff 148
0 Sergey Alexandrovich Kryukov 9,395
1 OriginalGriff 5,473
2 Peter Leow 4,150
3 Maciej Los 3,540
4 Abhinav S 3,333


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