Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Permanently Deleting A File

Posted on 2003-03-07
Medium Priority
Last Modified: 2010-04-17
I want to permanently delete a file from a VB Application.
Does the KILL Statement permanently delete file or can it be recovered from the disk?
There are File Shredding softwares available, I want to do this programatically for a security component of an application.

Rocky Roggers.
Question by:Rocky_Roggers

Accepted Solution

SimesA earned 150 total points
ID: 8087009
To "shred" a file:
Open the file, then write zeros, random data or anything else over the top of it. Do this for the full length of the file. Then close it and delete it.

If it's receovered from disk, they only recover your garbage.

Expert Comment

ID: 8087022

With kill you can recover a file from disk. You need low-level access to disk. I'm sorry but I don't know how to do that in VB.

Author Comment

ID: 8087096
Hi SmilesA,

Kindly clarify these points, some might sound naive,but I need to be absolutely clear as it is regarding security.

1.Before deleting, If I copy the file contents into a Floppy drive, by using the FileCopy API :

FileCopy "C:\MyDataFile","A:\MyBackupFile"

then will it result in creation of a .TMP File, which also will have to be deleted?

2. If a .TMP file is created,then how do I know its details like name and the path?

Thanks for your suggestion,
Rocky Roggers

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 8087168
Is this the same question? ;)

I just tried using the CopyFile API as you describe, but didn't see any temp file created. If one is created, I have no idea how you'd get its name.

But then, if the file copy API causes you a problem, don't use it. Write a simple file copy routine yourself that doesn't create temporary files.

BTW How can you be sure someone hasn't used Explorer to make their own copy?

Expert Comment

ID: 8087356
Try asking wipe tools creators (e.g. http://www.r-tt.com/RWipeClean.shtml ) to provide you with such API. But I guess it will cost 10-100 times more than just a wiper ... Writing wiper youself will take A LOT of time since you will need raw access to the NTFS drive which requires ... Writing NTFS FS parser. Go ahead, but it won't be an easy task.

Expert Comment

ID: 8097309
>To "shred" a file: Open the file, then write zeros, random data or anything else over the top of it. Do this for the full length of the file. Then close it and delete it.

Sorry :) This will not work for NTFS or any other modern file system with standard-complying quality. It would work 5 years ago but now you need to:
* clean streams associated with file
echo "this is a text file" > C:file.txt
echo "this is the alternate data stream lkajhkl2" > 
* clean memory file cache (in windows using it you can recover a file you shreded 10 hours ago)
Also latest windowses can try defragment file on rewrite means information with with you rewrite the file can be stored in separate defragmented block and this way you will not overwrite an old file contents (however recovery will be kind of hard since MFT will have no links to this data).

Given solution is only suitable if you want to hide your data from someone who's not going to pay money for it's retrival. It's not even suitable for commercial use.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question