Hi I need to read the sector 0 of a USB stick and make it removable. How can I do that? I am using C#, VS2008
+1
A:
I can help you with the second part: safely removing it.
Here's an article about a tool from Microsoft that will allow you to safely remove a flash drive from the command line. Using C# then, you can execute command line tools using the Process class.
Update:
You might investigate the windows API function CreateFile for reading raw disk sectors. You'll need use p/invoke to do this.
Another Update:
I did a search for you, and other people have had some success p/invoking to CreateFile using:
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(string lpFileName, System.UInt32 dwDesiredAccess, System.UInt32 dwShareMode, IntPtr pSecurityAttributes, System.UInt32 dwCreationDisposition, System.UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile);
Good Luck!
Charlie Salts
2010-07-09 20:28:16