I've been scouring the internet trying to find the answer to this and can't seem to find anything.
I'm making myself a new Folder Browser UserControl using a TreeView as an excercise to try and learn more about C#, and to add into a File Renaming program I've been developing.
I've found that the TreeView is a little small for my touchscreen laptop, so I've taken it on myself to recreate it with bigger icons and + symbols.
Now, first thing's first, I'm obtaining a list of drives (both local and network) to add into my TreeView, but I can't seem to get all the information I require.
In My Computer (I'm using Windows XP but I'm going to test on other versions where it says This Computer as well) there are 11 objects showing
Edited due to work
Using System.IO I can obtain some of what is showing but not all of it.
The options I have available are: AvailableFreeSpace DriveFormat DriveType IsReady Name RootDirectory TotalFreeSpace TotalSize VolumeLabel
Using P:\ as an example I get the following:
AvailableFreeSpace = 30102499328
DriveFormat = NTFS
DriveType = Network
IsReady = True
Name = P:\
RootDirectory = P:\
TotalFreeSpace = 30102499328
TotalSize = 4397611224320
VolumeLabel = FileSystem6 (3Par)
So, none of the options gives me the EDITED detail that shows in My Computer.
Can anyone tell me how I can get this information?
Any help would be much appreciated.
You should be able to get what you need using WMI. Add a reference to System.Management.dll and try the following:
System.Management.ManagementClass mc = new System.Management.ManagementClass("Win32_LogicalDisk");
System.Management.ManagementObjectCollection moc = mc.GetInstances();
if (moc.Count != 0)
{
foreach (System.Management.ManagementObject mo in mc.GetInstances())
{
string providerName = string.Empty;
if (mo["ProviderName"] != null)
{
providerName = mo["ProviderName"].ToString();
}
Console.WriteLine("\nName: {0}\nVolume Name: {1}\nProvider Name: {2}",
mo["Name"].ToString(),
mo["VolumeName"].ToString(),
providerName);
}
}
See http://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx for other properties of the Win32_LogicalDisk class.