Solved

Get Drive Letters in C#

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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