Saturday, June 12, 2010

How to : Detecting CD Drive from C#

Recently i was writing a custom application which installs on client machine in that i need to find the client CD driver letter.

Here is an example code snippet for finding driver letter.

System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
foreach (System.IO.DriveInfo drive in drives)
{
  if (drive.DriveType == System.IO.DriveType.CDRom)
  Console.WriteLine(drive.DriveType +"*********" +drive.Name);
}

No comments:

Post a Comment