Geekpedia Programming Tutorials






How to get all logical drives on a system?

On Wednesday, July 14th 2004 at 12:00 AM
By Andrew Pociu (View Profile)
****-   (Rated 4 with 2 votes)
Advertisement
More C# Resources
By calling a static method from System.Environment called GetLogicalDrives(). This returns a string array that you can easily iterate.
Suppose you have a ListBox and a button:

private void btnPopulate_Click(object sender, System.EventArgs e)
{
   // Store in a string array
   string[] drives = Environment.GetLogicalDrives();
   // Loop into the string array
   foreach(string strDrive in drives)
   {
      // Add items (drives) to the list
      listBox1.Items.Add(strDrive.ToString());
   }
}
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this Knowledge Base article
Comment Current Comments
by Arvind Kumar on Monday, November 21st 2005 at 05:27 PM

Good and very useful for me, Thank You

by shakeel on Wednesday, September 12th 2007 at 05:06 AM

Great stuff, <a href=\"http://www.simplytheticket.com\">Shakeel</A>

by on Saturday, October 20th 2007 at 05:43 PM

Thanks
saved me some time getting it to work myself.

by Kannan on Friday, December 14th 2007 at 11:38 AM

Very useful. Thanks.

by rabih ayoub on Wednesday, January 9th 2008 at 05:53 AM

how to get logical drive on the client side using asp.net

by venkat on Thursday, March 20th 2008 at 01:51 AM

hi rabih ayoub.
i want same u..
how to get the all drives of the client system.
if u got that send me..

by Srizzler on Wednesday, March 4th 2009 at 08:03 PM

Hi Guys:

Can anyone tell me how to get network folders/mapped drives thru C#. Environment.GetLogicalDrives will only get Machine's Local Drives.

Please help me out.

Thanks in Advance.
Srizzler.

by AyrA on Monday, June 8th 2009 at 01:02 AM

Iterate trough a String "abce....xyz" with .ToCharArray() in a foreach loop. Then simply try with the new System.IO.DriveInfo(letter) if the Drive exists
AyrA
http://ayra.ch

by Wasiqs on Friday, October 2nd 2009 at 10:31 AM

simpliest way: DriveInfo.GetDrives()

by gopal on Saturday, March 13th 2010 at 01:21 AM





it's very useful
Thanks dude


Comment Comment on this Knowledge Base article
Name: Email:
Message:
Knowledge Base Related Knowledge Base Articles
There are no related KB articles.

Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs C# Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons