...

View Full Version : Help with this VB code



aning
01-19-2005, 05:30 PM
'**************************************
' Name: *** Destroy a file without getti
' ng error! ***
' By: Matt Evans
'This code is copyrighted and has limite
' d warranties.
'Please see http://www.Planet-Source-Cod
' e.com/xq/ASP/txtCodeId.1650/lngWId.1/qx/
' vb/scripts/ShowCode.htm
'for details.
'**************************************



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 'wi
' pe-out' characters
Const BLOCKSIZE = 4096
Block1 = String(BLOCKSIZE, "X")
Block2 = String(BLOCKSIZE, " ")
'Overwrite the file contents with the wi
' pe-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 cont
' ains no sensitive data
Kill sFileName
End Sub

----------------------------------
I sure do know what the script does... but i just can't figure out how to make this code to work!! Can anyone get me the code! thank you... I'm learning VB since new weeks now and i guess its gonna take a long time for me... :p

oracleguy
01-20-2005, 09:45 AM
I didn't actually try the code but what doesn't work? Like what kind(s) of errors are you getting? Maybe post more code showing how you are using this code in your program.

aning
01-20-2005, 06:24 PM
oh thanx for the reply... i have finally made it to work but the code seems to work in the way i dont want it to...lol



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum