Identifying the drives available on a system

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

Hi there everyone,

I'm hoping that someone could point me in the direction of the necessary
classes required to determine information on a computers filesystem. In
particular, how can enumerate the drives that a computer has.

I need to identify the drives available, along with their types (cd, dvd,
disk etc) and then I need to make a tree structure that shows the users the
drives present. Very similar to Explorer really.

Any help would be great

Thanks all

Simon
 
System.IO.Directory.GetLogicalDrives() gets you a list of all drives.

For more detailed info (like types) you can use :

ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * From
Win32_LogicalDisk ");
ManagementObjectCollection queryCollection = query.Get();

HTH

Yves
 
Simon,

You should be able to use the classes in the System.Management namespace
and query for all instances of the Win32_DiskDrive WMI class. It should
give you the information about the drives on the system that you are looking
for.

Hope this helps.
 
Back
Top