Destroying files in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dariophoenix
    New Member
    • Oct 2006
    • 34

    Destroying files in C

    Hi,
    I am working in Windows XP and I need to destroy a file in a C program (not just erase its contents). The file was opened this way:

    Code:
    FILE* pBinFile = fopen(nameBinFile,"w+b");
    After that, I write data into the file. Finally, I try to destroy it with these instructions:

    Code:
    remove(nameBinFile);
    fclose(pBinFile);
    But the only effect is erasing the file's contents. How can I destroy it effectively?
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    try closing the file then removing it, e.g.

    fclose(pBinFile );
    remove(nameBinF ile);

    Comment

    • dariophoenix
      New Member
      • Oct 2006
      • 34

      #3
      It worked!! Thanks a lot!!

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        If this is a security program, writing data to the file will not destroy the contents it will still be recoverable. You need to make sure you have inerted all the bits of the file several times and then write a random pattern to the file.

        Comment

        Working...