Search code examples
windowsfile-ioerase

Permanent delete a file using C# or C++


Possible Duplicate:
C# - Deleting a file permanently

I read some articles how data recovery software are working. They said that deleted files are still on the HDD but are invisible for the OS. The files are in the same location (memory), but the pointers are different, this is why the OS can't see them.

I want to build a program in C# or C++ which can help me to completely erase files defined by me. Is it enough to use remove() (C++) to remove files permanently? Where should I start my documentation or what I am supposed to do?


Solution

  • Simply told, when files are deleted the "pointer" to the first block of data is deleted. But the data is still on the disk. If consequent writes are performed to the disk, there is a chance that the data will be overwritten.

    This is very simply told what "unerease" programs do. They search the disk for data that is there, but has no "pointer" in the data structures the file system has.

    What is required is usually that the blocks of data are overwritten.

    This can be done a number of times, to ensure that data can't be restored.

    There are a lot of programs that do that already, thought I'm not suire C# can do it (without resorting to unmanaged code).

    See C# - Deleting a file permanently for details.