Click here to Skip to main content
12,629,804 members (28,046 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB 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
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 12 Jan 2013
Copyright © CodeProject, 1999-2016
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