Getting name of cd in cdrom

I can use the Directory and DirectoryInfo to get every bit of information about the files contained on a CD in the drive.  I can use the DriveInfo to get all the specifications about the CDRom with the exception of the Name assigned to the actual CD.  The best I can get is the Drive letter and volume label.  The volume label is not always the same as the cd name.  For example, I have my bluetooth driver CD in at the moment.  The name is KensingtonBTW.  The volume label is something like 09893-0933.  I have been unsuccessful finding a way to get to the "KensingtonBTW" name.

System.IO.
DriveInfo d = new System.IO.DriveInfo("D");
MessageBox.Show(d.Name);  //"D:\"
MessageBox.Show(d.VolumeLabel); //"09893-0933"
MessageBox.Show(d.ToString());  //"D:\"

Any assistance appreciated,
Mark


Answer this question

Getting name of cd in cdrom

  • shailesh.d.g

    you'll not be able to get native .net apis to do this, so you'll require to do PInvoke some methods required. Here's a series of articles that would help you get the device name. That's what you're looking for.

    http://www.codeproject.com/csharp/DivingSysProg1.asp
    http://www.codeproject.com/csharp/DivingSysProg2.asp
    http://www.codeproject.com/csharp/DivingSysProg3.asp

    You'll only require to read part 1 and part 2 to get the device name. But for completeness, part 3 explains how to get back the device resources.

    I hope that helps.


  • MikeLammy

    What do you consider to be the name of the CD   As far as I'm aware Windows will only show the volume label which is obtained from the CD itself.  Some CDs use their serial number but most use a name specified when the CD was created.

    Michael Taylor - 12/14/05

  • Chosie

    Thanks for the responses.

    I discovered the solution to my problem today.  The volume label is the name of the CD as assigned when created, but I was unaware of the fact that there is a [Label] in the autorun.inf file that is somehow used to change the name shown in the titlebar and icon to be different from the volume label. 

    Thanks again,

    Mark


  • Getting name of cd in cdrom