C
cmsimmers
I'm trying to display the available space on a disk drive. This could
be tricky if the user choose a drive on which they are limited to a
quota. The "FreeSpace" property returns the total number of bytes on
the disk, which could be significantly larger than the space actually
available to the user.
I found documentation referring to VB scripting, which provided an
"AvailableSpace" property, in addition to the "FreeSpace" property.
http://groups.google.com/group/micr...st&q="AvailableSpace"&rnum=2#1417285711e11c94">Google
** sorry for this long URL, couldn't figure out how to make it a link
Is there an analog to this in C# / .NET WMI?
Here's some sample code in case I haven't been clear about what I'm
doing:
private String GetFreeSpace(String inVolume)
{
ManagementObject disk = new
ManagementObject("win32_logicaldisk.deviceid=\"" +
inVolume + "\"");
disk.Get();
int megabytes = (int)((Convert.ToInt64(disk["FreeSpace"]) /
1024) / 1024);
// does something like this property exist?
//int megabytes = (int)((Convert.ToInt64(disk["FreeSpace"])
/ 1024) / 1024);
return megabytes.ToString();
}
be tricky if the user choose a drive on which they are limited to a
quota. The "FreeSpace" property returns the total number of bytes on
the disk, which could be significantly larger than the space actually
available to the user.
I found documentation referring to VB scripting, which provided an
"AvailableSpace" property, in addition to the "FreeSpace" property.
http://groups.google.com/group/micr...st&q="AvailableSpace"&rnum=2#1417285711e11c94">Google
** sorry for this long URL, couldn't figure out how to make it a link
Is there an analog to this in C# / .NET WMI?
Here's some sample code in case I haven't been clear about what I'm
doing:
private String GetFreeSpace(String inVolume)
{
ManagementObject disk = new
ManagementObject("win32_logicaldisk.deviceid=\"" +
inVolume + "\"");
disk.Get();
int megabytes = (int)((Convert.ToInt64(disk["FreeSpace"]) /
1024) / 1024);
// does something like this property exist?
//int megabytes = (int)((Convert.ToInt64(disk["FreeSpace"])
/ 1024) / 1024);
return megabytes.ToString();
}