|
-
Aug 30th, 2000, 02:47 PM
#1
Thread Starter
Member
I thought it was Remove(filename)
but i guess not, I don't have any VB help files on my comp so if someone could enlighten me I'd be a happy camper 
-Brad
-
Aug 30th, 2000, 02:49 PM
#2
Fanatic Member
Code:
Kill(Filename As String)
-
Aug 30th, 2000, 02:53 PM
#3
Thread Starter
Member
When did VB get this violent??
-
Aug 30th, 2000, 03:11 PM
#4
_______
<?>
It's a good idea to check for the file's existance
since you will generate an error if the file isn't found
Code:
'does file exist using fso
Dim sFile$
sFile = "Name And Path Of Your File"
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists(sFile$) = True Then
MsgBox "File Exists...Your code here!"
Else
MsgBox "Does Not Exist...Your code here!"
End If
Set fs = Nothing
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 30th, 2000, 03:27 PM
#5
You could also use this code and erase all the contents in a file and then delete it.
Code:
Sub DestroyFile(sFileName As String)
Dim Block1 As String, Block2 As String, Blocks As Long
Dim hFileHandle As Integer, iLoop As Long, offset As Long
'Create two buffers with a specified 'wipe-out' characters
Const BLOCKSIZE = 4096
Block1 = String(BLOCKSIZE, "X")
Block2 = String(BLOCKSIZE, " ")
'Overwrite the file contents with the wipe-out characters
hFileHandle = FreeFile
Open sFileName For Binary As hFileHandle
Blocks = (LOF(hFileHandle) \ BLOCKSIZE) + 1
For iLoop = 1 To Blocks
offset = Seek(hFileHandle)
Put hFileHandle, , Block1
Put hFileHandle, offset, Block2
Next iLoop
Close hFileHandle
'Now you can delete the file, which contains no sensitive data
Kill sFileName
End Sub
Usage:
Call DestroyFile("C:\program.exe")
-
Aug 30th, 2000, 03:58 PM
#6
Fanatic Member
Matthew, why would you overwrite it one time. I thought a file is only secure deleted when it's 5 times overwritten.
-
Aug 30th, 2000, 04:21 PM
#7
No need. That code erases all the contents in the file. Than simply uses the Kill function to remove it.
See for yourself, remove the Kill sFileName and then open the file in Edit and you will see the file has been wiped out completely.
So if you were to do it 5 times, it would not make a difference than if you did it once.
-
Aug 30th, 2000, 04:58 PM
#8
You can also the Dir() function, you can check if the file exsists or not.
Code:
If Dir$("MyfileName") <> "" Then
'File exsists
Else
'File Does not exsist
End If
-
Aug 30th, 2000, 05:24 PM
#9
So Unbanned
Is there any point to over-write all data in the file before deleting?
-
Aug 30th, 2000, 05:30 PM
#10
Monday Morning Lunatic
If you just delete it, all it does is mark the file's clusters as free. The contents of the file will still be on the disk. In a secure environment, you will not want this.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 30th, 2000, 05:31 PM
#11
Thread Starter
Member
That *ROX*
I thought I would have to empty the recycle bin after deleting
Wiping out the whole file *first* is definetely a plus.
I'm going to be having sensitive data in an encrypted file. After I decrypt it and write the normal file to access vars from I simply encrypt again and delete the unencrypted file.
Wiping out the whole thing in one shot will definetely put me more at ease, thanx man!
and to think... I was just going to 'Kill' it...
heh
-Brad
-
Aug 30th, 2000, 07:19 PM
#12
Frenzied Member
Oetje's allmost right
Matthew, I read that a file is really secure deleted when it's 7, yes 7 times overwritten, don't ask me why, but it's true according to a Danish File Securing company which rescues lost data.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Aug 30th, 2000, 07:47 PM
#13
Really? 7 times? That's a lot. But to the point, if you tried that code, it has erased everything inside the file. So even if you were to retrieve it with a file restorer (or whatever they're called), you'll have the file, but nothing in it. It will be a totally useless file. If you just use the Kill function to remove the file, you could probably restore it and be able to use the file again.
-
Aug 30th, 2000, 07:55 PM
#14
Frenzied Member
Yeah I couldn't believe that neither.
Dunno why, but it's considered DELETED with no chance of *ever* backuping it when it's overwritten 7 times or something
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Aug 30th, 2000, 10:44 PM
#15
Conquistador
you could also open it for output then delete it
i.e
Code:
Open "c:\tobdeleted.enc" For Output As #1
Write #1, ""
Close #1
Kill "c:\tobdeleted.enc"
i think it would work 
but just kill is the easiest method
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|