|
-
Jul 28th, 2000, 11:01 AM
#1
Thread Starter
Frenzied Member
how do I delete a file?
like do I write:
will that work
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
NXSupport - Your one-stop source for computer help
-
Jul 28th, 2000, 11:06 AM
#2
Frenzied Member
deleting a file
Have you tried KillDoc?
KillDoc ("C:\a.dat")
Hope this helps.
-
Jul 28th, 2000, 11:07 AM
#3
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jul 28th, 2000, 11:12 AM
#4
Addicted Member
Code:
Kill "**filename**"
Visual Basic 6 Enterprise Edition + SP4
-
Jul 28th, 2000, 11:13 AM
#5
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jul 28th, 2000, 11:17 AM
#6
Frenzied Member
No need
Hey.
No need to try both.
That's Kill.
Sorry, it's after midnight here in Beijing.
-
Jul 28th, 2000, 11:19 AM
#7
Thread Starter
Frenzied Member
so which 1 is the correct one?
NXSupport - Your one-stop source for computer help
-
Jul 28th, 2000, 11:25 AM
#8
Frenzied Member
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
-
Jul 28th, 2000, 11:25 AM
#9
Kill "filename"
is the right one.
-
Jul 28th, 2000, 11:26 AM
#10
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jul 28th, 2000, 11:26 AM
#11
Frenzied Member
PS
KillDoc is for killing a print job in code.
-
Jul 28th, 2000, 11:27 AM
#12
Thread Starter
Frenzied Member
thanks, I'll keep that in mind if I ever need it
NXSupport - Your one-stop source for computer help
-
Jul 28th, 2000, 02:14 PM
#13
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
-
Jul 28th, 2000, 03:10 PM
#14
Thread Starter
Frenzied Member
thanks but I dont think that its nessessary for my pruposes
NXSupport - Your one-stop source for computer help
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
|