how do I delete a file?
like do I write:
will that workCode:del "c:\a.dat"
I haven't tried it yet
or maybe thats not what to do to delete a file
so. how do I delete a file trough VB
thanks in advance
Printable View
how do I delete a file?
like do I write:
will that workCode:del "c:\a.dat"
I haven't tried it yet
or maybe thats not what to do to delete a file
so. how do I delete a file trough VB
thanks in advance
Have you tried KillDoc?
KillDoc ("C:\a.dat")
Hope this helps.
ok, thanks
Code:Kill "**filename**"
thanks, I'll try both
Hey.
No need to try both.
That's Kill.
Sorry, it's after midnight here in Beijing.
so which 1 is the correct one?
GFK is right.
As I said, it's after midnight here.
Code:
Kill ("C:\autoexec.bat")
Of course you may want to change the last part of that code:)
Kill "filename"
is the right one.
Ok, thanks to all
PS
KillDoc is for killing a print job in code.
thanks, I'll keep that in mind if I ever need it
Just to screw with your mind a bit more, I like this code better. It erases all the contents in a file and then deletes the file.
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
thanks but I dont think that its nessessary for my pruposes