Solved

Get Drive Letters in C#

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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!
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now