Click to See Complete Forum and Search --> : Access name of Removable drive
mikepcx
July 13th, 2006, 12:37 PM
I needed to know how to get the name of a removable drive in C#. Not the drive letter (such as A:\), but the name. When I got an external hdd, I named it "External HDD" and thats what shows up on my computer: "External HDD (A:)" but how would I get the "External HDD" text? (I can also use C++ if need be).
mcmcom
July 13th, 2006, 12:54 PM
check this link:
http://www.codeproject.com/csharp/my_explorer.asp
there should be a property of the object that GetDrives() uses. that will allow you to get the drive name (please not you may get the drive name followed by the letter) Such as
External HDD (A:) but you can trim or split the string to get what you want.
hth,
mikepcx
July 13th, 2006, 01:08 PM
Scratch that whole text in brackets below. You were right. I went to MSDN and looked up all the properties I can obtain from the ManagementObject, and "VolumeName" was one of them which gives me exactly what I need (and I don't need to parse). Thanks for the help
{
I have checked out the MyExplorer on code project. It uses Management objects to query the information from windows, however the ["Name"] returns the drive letter. GetDrives() does not appear in the source at all. If you mean System.IO.Directory.GetLogicalDrives(), it returns a string[] of drive letters, as does System.Environment.GetLogicalDrives(). Did you see GetDrives() somewhere?? If so, does it return the name (not drive letter)??
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.