ManagementObjectSearcher query = new
ManagementObjectSearcher("SELECT * From Win32_LogicalDisk");
ManagementObjectCollection queryCollection = query.Get();
foreach ( ManagementObject mo in queryCollection)
{
switch ( int.Parse( mo["DriveType"].ToString( ) ) )
{
case Removable: //removable drives
break;
case LocalDisk: //Local drives
Console.WriteLine( "Local drive found:\t" + mo["Name"] );
break;
case CD: //CD rom drives
Console.WriteLine( "Local CD found: \t" + mo["Name"] );
break;
case Network: //Network drives
break;
}
}
Which works great for determining what drive letter it is and what KIND of drive it is. But I can't find the magic bullet that allows me to actually alter the drive letter itself. I found some references to WMI in script to do it:Active Experts Website link
But my n00bie brain is having a hard time finding the equivalent piece of code in c#. Thanks everyone.
Replies
Know the answer? Post it — somebody with the same question will find it here.