Accessing resource on unknown CD-ROM (drive letter).
-
Say some of our program resource is on CD, but we don't know which one (and want to use any available), what is best way to check available drives, and then check if disk we want is one of them?
-
Say some of our program resource is on CD, but we don't know which one (and want to use any available), what is best way to check available drives, and then check if disk we want is one of them?
If using .NET 2.0 there is System.IO.DriveInfo which gives you: - all the drive letters - so scan them one by one, and for each drive - check drive type (check for DriveType.CDRom) - check volume label (check for your CD's label). If using .NET 1.1 you can follow the same scheme, but you would need PInvoke to Win32 functions such as GetVolumeInformation (And that's exactly what I did today !) :)
Luc Pattyn
-
If using .NET 2.0 there is System.IO.DriveInfo which gives you: - all the drive letters - so scan them one by one, and for each drive - check drive type (check for DriveType.CDRom) - check volume label (check for your CD's label). If using .NET 1.1 you can follow the same scheme, but you would need PInvoke to Win32 functions such as GetVolumeInformation (And that's exactly what I did today !) :)
Luc Pattyn
Visual C# 2005 EE so it's 2.0, I'll try that now...
-
If using .NET 2.0 there is System.IO.DriveInfo which gives you: - all the drive letters - so scan them one by one, and for each drive - check drive type (check for DriveType.CDRom) - check volume label (check for your CD's label). If using .NET 1.1 you can follow the same scheme, but you would need PInvoke to Win32 functions such as GetVolumeInformation (And that's exactly what I did today !) :)
Luc Pattyn
OK got it thanks... link for good example on that: http://msdn2.microsoft.com/en-us/library/system.io.driveinfo.getdrives.aspx