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 :)
Loading
Jan MontanoPosted Jun 30, 2008, 5:44 AM
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;
}
}
Vaxo NozadzePosted Jun 29, 2008, 2:51 AM
Scott LyslePosted Jun 28, 2008, 7:23 PM
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);