Solved

Get Drive Letters in C#

Posted on 2008-10-17
2
5,816 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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