I'm trying to detect a CD-ROM drive in an app, I'm using
ComboBox cb = new ComboBox();
var drives = DriveInfo.GetDrives();
foreach (var drive in drives)
{
if (drive.DriveType == DriveType.CDRom)
{
cboDrives.Items.Add(drive);
}
}
It picks up D:\ and E:\
D:\ is the real CD-ROM on my work PC, E:\ is a virtual drive through Alcohol 120%
I'm creating an app to read optical media to an ISO then I'm mounting that ISO in Alcohol to test if the ISO is Okay.
I want to make it easy for the users, when creating an ISO they have only one drive to choose and same for the testing of the ISO.
I could try and filter out the drive letter D:\ when the part of my app that tests ISO's is run but not all PC's have D:\ as their CD drive, my Win8.1 box for example has it as J:... and with two virtual CD drives (Alcohol and Virtual clone drive) G:\ and N:.
Is there a way to pick up the real CD drive letter by itself and then same for the virtual ones?
Update Interestingly, I've found that by testing if the drive Is Ready then only the CD drive gets picked up since it contains media whereas the virtual drive does not. Once media is mounted then it gets picked up, I think I can do something with this and/or with the duplicate question answer.
ComboBox cb = new ComboBox();
var drives = DriveInfo.GetDrives();
foreach (var drive in drives)
{
if (drive.IsReady == true)
{
if (drive.DriveType == DriveType.CDRom)
{
cboDrives.Items.Add(drive);
}
}
}