This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var driveQuery = new ManagementObjectSearcher("select * from Win32_DiskDrive"); | |
foreach (ManagementObject d in driveQuery.Get()) | |
{ | |
var deviceId = d.Properties["DeviceId"].Value; | |
//Console.WriteLine("Device"); | |
//Console.WriteLine(d); | |
var partitionQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_DiskDriveToDiskPartition", d.Path.RelativePath); | |
var partitionQuery = new ManagementObjectSearcher(partitionQueryText); | |
foreach (ManagementObject p in partitionQuery.Get()) | |
{ |