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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI


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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
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…
Suggested Courses

777 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