Click here to Skip to main content
13,003,370 members (56,829 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, I have a CDROM drive which is ready (I think so, because I can open a disc using it without having any problem), but I tried getting its volume label and there was an exception saying "The device is not ready":

Here is my code:
DriveInfo cd = new DriveInfo("F"); //My CD ROM drive

How can I get its volume label?

Your help would be highly appreciated! Thanks!
Posted 17-Sep-12 5:14am
Updated 17-Sep-12 5:59am
Alan N 17-Sep-12 12:20pm
The volume label is associated with a disk. Is there one in the drive?
Wes Aday 17-Sep-12 13:03pm
I think that you probably have the right answer here.
supernorb 17-Sep-12 13:28pm
Thank you, why didn't you give your answer to my question?
Yeah, my drive didn't have any disk, and after inserting a one, it worked! Thanks again!

However, my CD Ejector became useless when it can't eject my CD Drive when the drive has a disk, I just tested when the drive didn't have a disk. I collected the code at StackOverFlow, well, it seems to be rather complicated, I used winmm.dll and it works well, but with CreateFile and dozens of other functions don't work!

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Check for cd.IsReady flag,if it is false the device is not actually ready and you can put the code to sleep and try again.If it is always false then there is a problem with the Drive.
supernorb 17-Sep-12 13:15pm
Of course, the cd.IsReady is false, but in fact there is not any problem with my drive, it is still working properly.
My want is how to get the VolumeLabel of a CD ROM drive, my approach using DriveInfo seems to be not feasible, Thanks

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170626.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100