Search code examples
.netwinapidisk

How do I read a disk directly with .NET?


Is it possible to read a disk directly with .NET? By directly, I mean via the device bypassing the file system. I think I would go about this by opening the device some way "\Device\Ide\IdeDeviceP2T0L0-1" for example.

If I can't open the device with a .NET API, knowing which Win32 API to use would be helpful.


Solution

  • CreateFile has support for direct disk access. Read the notes under "Physical Disks and Volumes". You should be able to P/Invoke the call.

    Note that Vista and Server 2008 have severely restricted this.