"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:uD**************@TK2MSFTNGP06.phx.gbl...
| Scott Bell wrote:
| Hello all,
| >
| What is the equivalent in the .NET Framework for accessing
| a device at the block/sector level such as one would when
| using CreateFile on a device like "\\.\D:"? Attempting to create
| a BinaryReader on a FileStream opened (read-only) on "D:"
| yields an Access Denied exception.
|
| Use P/Invoke to call CreateFile and ReadFile directly passing in the
| appropriate options to open a device.
|
|
http://www.pinvoke.net/default.aspx/...reateFile.html
|
http://www.pinvoke.net/default.aspx/.../ReadFile.html
|
| -cd
|
|
Note that there is no need to Pinvoke Win32's ReadFile, the handle (use a
SafeHandle in V2) returned by CreateFile can be used to create a FileStream,
this class has a number of contructor overloads that take an IntPtr
(representing the handle) or a SafeHandle.
Willy.