forum

home / developersection / forums / get drive letter and name using c#

Get Drive Letter and Name using C#

Dag Hammarskjold 7403 16-Oct-2013

I am suffering with a program that is how can I get hard disks/ usb's, but it only returns me the drive letter not the name.

DriveInfo[] driveInfo = DriveInfo.GetDrives();

Console.WriteLine("Detected Drives: ");
for(int i = 0; i < driveInfo.Count(); i++)
{
     Console.WriteLine("Drive " + i + ": " + driveInfo[i].Name);
}
return driveInfo;

and this prints:

Drive 0: C:\

Drive 1: E:\

but I want the name such as

Drive 0: C:\ Local disk
Drive 1: E:\ SacnDisk USB

How can I perform that task please help me!


c# c# 
Updated on 16-Oct-2013
Can you answer this question?

Answer

1 Answers

Liked By