Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Direct disk access in windows (C#)

Tags:

c#

disk

I want to be able to read and write data directly to and from a disk (i.e. at a sector / cluster level) but I've yet to find a suitable tool for doing this under windows.

I've been trying to figure out how to write my own in C#, but the documentation I've found is sparse and only deals with C++ APIs.

Whats the best way of reading /writing directly to / from a drive in C#? (or can anyone recommend me a tool that allows me to read / write directly from a drive?)

like image 312
Justin Avatar asked Sep 09 '09 12:09

Justin


2 Answers

pinvoke.net has a collection of managed code wrappers for essentially all Win32 API's, including those that can talk to the Disk Manager service and perform low level kernel/IO.

like image 126
Jason Avatar answered Oct 13 '22 20:10

Jason


Honestly, you probably need to look at Platform Invoke if you want to write this code in C#. It lets you interact with unmanaged platform APIs, which you mentioned is the bulk of the information you've found so far :-)

like image 2
Joel Martinez Avatar answered Oct 13 '22 20:10

Joel Martinez