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());
}
}
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