Solved

Get Drive Letters in C#

Posted on 2008-10-17
2
5,786 Views
Last Modified: 2008-10-17
I need to know how to get the drive letter of a physical drive in C#.  Preferably, I would like to loop through the drives currently connected and display their drive letters.  Could someone help me with this?
0
Comment
Question by:jason4659
2 Comments
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 400 total points
ID: 22744696
string[] drives = Directory.GetLogicalDrives();


check this also

http://bytes.com/forum/thread276247.html
0
 
LVL 18

Assisted Solution

by:Priest04
Priest04 earned 100 total points
ID: 22744756
That code will retrieve all drive letters, including optical drives. To get only fixed drive letters, try this code


string[] drives = System.IO.Directory.GetLogicalDrives();
 
foreach (string drive in drives)
{
    System.IO.DriveInfo info = new System.IO.DriveInfo(drive);
    if (info.DriveType == System.IO.DriveType.Fixed)
    {
        // do what you want with it
    }
}

Open in new window

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question