Gaining access to the File Allocation Table in C# or any other direct drive access

If you try to open a drive directly with C# classes (like FileStream) you will encounter a runtime error. Basically what you want to do is open the file „\\.\X:“ for a single partition, or if you want to gain access to the physical drive with the partition table and everything „\\.\PhysicalDrive0“. This will result in:

“FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of „\\.\“ in the path.”

Some confusion might occur when you try to open a „normal“ path and still receive some error messages, there are still some reserved keywords which cannot be used (like PRN or CON).

To get around this problem, what you have to do is take a P/Invoke to call the Win32-API function CreateFile() from kernel32.dll.
› Continue reading

Tags: , ,

Sonntag, Februar 27th, 2011 Computer, Software 3 Comments
profile for Arsenal on Stack Exchange, a network of free, community-driven Q&A sites


• Hosted by netcup.de

Durch die weitere Nutzung der Seite stimmst du der Verwendung von Cookies zu. Weitere Informationen

Die Cookie-Einstellungen auf dieser Website sind auf "Cookies zulassen" eingestellt, um das beste Surferlebnis zu ermöglichen. Wenn du diese Website ohne Änderung der Cookie-Einstellungen verwendest oder auf "Akzeptieren" klickst, erklärst du sich damit einverstanden.