Answer the question
In order to leave comments, you need to log in
How to write bytes to a specific disk sector c#?
Good day to all.
I am writing a program for guaranteed data destruction. The question arose about overwriting clusters where the file is located. At the current stage, it is not possible to jump to the specified position on the disk. Tried to use a function that SetFilePointer
returns -1.
SafeFileHandle hDrive = CreateFile("\\\\.\\" + fileRoot, GENERIC_WRITE, FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero);
if (SetFilePointerEx(hDrive, start, &start2, 0) != -1)
{
...
WriteFile(hDrive, buff, buff.Length, &retBytes, null)
}
Answer the question
In order to leave comments, you need to log in
I advise you to call GetLastError on an error and see what it returns. Without an error code - fortune-telling on the coffee grounds.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question