How to get total disc sectors in medium?

738 views Asked by At

I would like to get the number of total sectors on a medium inserted in CD-ROM drive. Is there method for this in C#? I've checked the Management class in .NET but that does not seem to have a method.

1

There are 1 answers

3
Jim Mischel On

The Windows API function DeviceIoControl will get that information for you. Unfortunately, there's no simple wrapper for it in the .NET libraries.

This sample shows how to do what you want in C. Translating that to C# is non-trivial, but you might find some helpful pointers here: Calling DeviceIoControl from C# with IOCTL_DVD_* Control Codes