?
Solved

Get Drive Letters in C#

Posted on 2008-10-17
2
Medium Priority
?
5,854 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 1600 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 400 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

777 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