Ikelca
asked on
setPropertyValue does not work with win32_volume?
here is my code, basically, i want to assign drive letter "H“ to a removable usb drive
but when I try to set value for drive letter, there is no exception or error, nth happens.
problem seems to be following line, but i couldnt find out how to fix it.
mo.SetPropertyValue("Drive Letter","H :");
im using win7 and tested with administrator previllage when running debug.
can someone please help?
but when I try to set value for drive letter, there is no exception or error, nth happens.
problem seems to be following line, but i couldnt find out how to fix it.
mo.SetPropertyValue("Drive
im using win7 and tested with administrator previllage when running debug.
can someone please help?
public static void Main(string[] args)
{
RetrieveDiskInfo_DriveLetter rdd = new RetrieveDiskInfo_DriveLetter();
ManagementClass mc = new ManagementClass("Win32_Volume");
ManagementObjectCollection moc =mc.GetInstances();
if(moc.Count!=0)
{
try{
foreach (ManagementObject mo in moc)
{
if (mo["DriveType"].ToString() == "2")
{
Console.WriteLine(mo["Drivetype"].ToString());
Console.WriteLine(mo["DeviceID"].ToString());
mo.SetPropertyValue("DriveLetter","H:");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
ASKER
tried, it does not work
ASKER
and no error msg, this is weird
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ummm thanks for the reply, it works now on win7
but somehow it gets unhandled exception on WINXP
the debugger points to ManagementObjectCollection moc = mc.GetInstances();
do you know how come this happens??
but somehow it gets unhandled exception on WINXP
the debugger points to ManagementObjectCollection
do you know how come this happens??
ASKER
nvm, i just found out win32_volume is not available to winxp and earlier windows.....
thanks guys
thanks guys
Open in new window