using System.Management;
This allows you to query the Win32_LogicalDisk WMI class and return a *huge* amount of information using the classlibrary using query language. For example, to get a collection of drives you could do the following.using System; using System.Management; namespace ConsoleApplication2 { class Class1 { static void Main(string[] args) { ObjectQuery objectQuery = new ObjectQuery("select * from Win32_LogicalDisk"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(objectQuery); foreach (ManagementObject DiskDrive in searcher.Get()) { Console.WriteLine("Drive = " + DiskDrive["Name"] + " FileSystem = " + DiskDrive["FileSystem"]); } } } }Now if you only wanted NTFS drives you could alter the query to look something like this.
select * from Win32LogicalDisk where FileSystem IS NOT "NTFS"If you want to get at the Win32_LogicalDisk class for a specific drive then you can use the following.
ManagementObject HardDrive = new ManagementObject("win32_logicaldisk.deviceid=\"c:\""); HardDrive.Get(); Console.WriteLine("Drive C: Logical Disk Size = " + HardDrive["Size"] + " bytes");The following represent the members available to the Win32_LogicalDisk class.
uint16 Access; uint16 Availability; uint64 BlockSize; string Caption; boolean Compressed; uint32 ConfigManagerErrorCode; boolean ConfigManagerUserConfig; string CreationClassName; string Description; string DeviceID; uint32 DriveType; boolean ErrorCleared; string ErrorDescription; string ErrorMethodology; string FileSystem; uint64 FreeSpace; datetime InstallDate; uint32 LastErrorCode; uint32 MaximumComponentLength; uint32 MediaType; string Name; uint64 NumberOfBlocks; string PNPDeviceID; uint16 PowerManagementCapabilities[]; boolean PowerManagementSupported; string ProviderName; string Purpose; boolean QuotasDisabled; boolean QuotasIncomplete; boolean QuotasRebuilding; uint64 Size; string Status; uint16 StatusInfo; boolean SupportsDiskQuotas; boolean SupportsFileBasedCompression; string SystemCreationClassName; string SystemName; boolean VolumeDirty; string VolumeName; string VolumeSerialNumberWhen you start looking beyond the Win32LogicalDisk class you will see there is a whole host of information you can get at like Win32_MappedLogicalDisk.