This is the code that I have for my query:
public String getDriveID()
{
String wow = @"win32_logicaldisk.deviceid=\" + @driveID;
ManagementObject disk = new ManagementObject(wow);
disk.Get();
Console.WriteLine(disk["Name"]);
return disk["Name"].ToString();
}
And this is what creates the driveID String that the method uses:
DriveInfo dInfo = therehasgottobeanotherway[driveList.SelectedIndex];
if (dInfo.IsReady) {
diskWMI dwmi = new diskWMI(dInfo.Name);
}
If you’re not familiar with the DriveInfo class, the Name attribute returns the name of the drive, for example c:\
I found this code online that does the EXACT same thing I’m trying to do, but I always get an error when I’m trying to use it:
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
disk.Get();
Console.WriteLine(disk["VolumeName"]);
Console.ReadLine();
I bet there is a formatting error happening but I can’t figure out what to change.
I’m trying to pass in a drives name where it has deviceid=
or for your existing example this will work for you