C # - Permanently deleting a file

I have been out of C # for some time since I started working with the iPhone, but how can you completely delete a file (so it is not stored in memory) and is not restored. If you cannot delete it permanently, can you split it into random data so that it cannot be opened, but still exists?

+2
source share
2 answers

Of course, you can overwrite the file so that the previous content could not be restored. But this must be done by the disk itself to make sure that the correct block is overwritten ... C # interacts with the file system and not with the physical blocks, therefore it does not provide any security.

The actual way to ask the drive to erase something safely depends on the interface (ATAPI vs SATA, vs USB mass-storage vs SCSI vs firewire), and C # does not provide an easy way to command at this level.

+2
source

sdelete execute this command through Process in C #.

 Process p = new Process(); p.StartInfo = new ProcessStartInfo( "cmd", "/c sdelete -p 1 -s -z -q -a 'path/to/director' ) { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true }; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); 

sdelete can be downloaded here

+2
source

All Articles