Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to add the CD drive list to Combo box.

How do I get that CD drive list?

Trickier than getting all the drives.



Add + Precisely, Only CD Drive on a System.
Posted
Updated 13-Jun-10 4:14am
v2

C#
// Get all drives on system and loop through them
System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
foreach (System.IO.DriveInfo drive in drives)
{
    // Is this a CD drive?
    if (drive.DriveType == System.IO.DriveType.CDRom)
        Console.WriteLine(drive.Name);
}
 
Share this answer
 
C#
ManagementObjectCollection drives = null;
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(
    "Select * from Win32_CDROMDrive"))
{
    drives = searcher.Get();
}
 
Share this answer
 
Your question is not very clear.

Do yiu want a list of all CD drives on a system, or a list of the contents of a CD?
 
Share this answer
 
Comments
rus204 13-Jun-10 10:13am    
Sorry. Precisely, Only CD Drive on a System.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900