Hello, i want to get logical drive in ComboBox
i have this code
[CODE]
DriveInfo[] Drive = DriveInfo.GetDrives();
foreach (DriveInfo LogicalDrive in Drive)
{
comboBox1.Items.Add(LogicalDrive);
switch (comboBox1.Items)
{
}
}
[/CODE]
but i do not know what must bee in switch
switch (?)
thanks beforehand :)
Get LogicalDrive
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Scott LysleRank #49 · 31K reputationPosted Jun 28, 2008, 3:23 PM EDT
I'm not sure what you are trying to do with the switch statement. If you just want to add all of the logical drives to a combobox control; you can do this:
string
[] drives = Directory.GetLogicalDrives();comboBox1.Items.AddRange(drives);
Vaxo Nozadze6 reputationPosted Jun 28, 2008, 10:51 PM EDT
Jan MontanoRank #1,295 · 1.3K reputationPosted Jun 30, 2008, 1:44 AM EDT
DriveInfo[] Drive = DriveInfo.GetDrives();
foreach (DriveInfo LogicalDrive in Drive)
{
comboBox1.Items.Add(LogicalDrive);
switch (LogicalDrive.Name)
{
case @"A:\":
// perform something
break;
case @"C:\":
// perform something
break;
default:
// perform something
break;
}
}