
namespace ChosenFileįoreach (var Drives in Environment.GetLogicalDrives()) With the help of Drive.IsReady u can avoid having DeviceNotReady or DeviceUnavailable issues.Īlso here is a simple "ChooseFile" example which includes a ComboBox for drives, a TreeView for folders and the last a ListBox for files. I would approach this with: foreach (var Drives in Environment.GetLogicalDrives())ĭriveInfo DriveInf = new DriveInfo(Drives)

I think the DriveInfo method is a lot more flexible. Where(d => d.DriveType = System.IO.DriveType.Network) And if you only want to show network drives, you can do this now: comboBox1.DataSource = System.IO.DriveInfo.GetDrives()

Now comboBox1.SelectedValue will be of type DriveInfo, so you'll get lots more info about the selected game. So you could start with this: comboBox1.DataSource = System.IO.DriveInfo.GetDrives() That way you can limit which drives apppear.

You can use the DriveInfo.GetDrives() method to enumerate the drives and bind the result to the ComboBox. Now you can handle the SelectedValueChanged event to take action when someone changes the selected drive.Īfter answering this question, I've found another (better?) way to do this. Drop one on your form, change its DropDownStyle to DropDownList to prevent editing, and in the Load event for the form, add this line: comboBox1.DataSource = Environment.GetLogicalDrives() There's no built-in control to do that, but it's very easy to accomplish with a standard ComboBox.
