Reputation: 375
I have this code:
DriveInfo dr = new DriveInfo(@"E:\");
if (dr.IsReady == false)
{
MessageBox.Show("Drive E: is not ready. Please insert a blank DVD medium.");
}
So, I insert a blank DVD in the drive and run the code. What am I missing?
Thanks a lot
Upvotes: 1
Views: 1015
Reputation: 913
DriveInfo.IsReady
on the blank DVD will return false.
If you need to distinguish if a blank disc is there, you'll need to use a different library. Here is a program that includes a interop wrapper around IMAPI2 (Window's Image Mastering API): http://www.codeproject.com/KB/miscctrl/imapi2.aspx
Use the interop wrapper and call
IDiscFormat2Data discFormatData = new MsftDiscFormat2Data();
if (discFormatData.CurrentMediaStatus == IMAPI_FORMAT2_DATA_MEDIA_STATE.IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK)
{
...
}
Upvotes: 2