Results 1 to 14 of 14

Thread: Deleting a file

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    how do I delete a file?

    like do I write:

    Code:
    del "c:\a.dat"
    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

  2. #2
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    deleting a file

    Have you tried KillDoc?

    KillDoc ("C:\a.dat")


    Hope this helps.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    ok, thanks
    NXSupport - Your one-stop source for computer help

  4. #4
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136
    Code:
    Kill "**filename**"
    Visual Basic 6 Enterprise Edition + SP4

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks, I'll try both
    NXSupport - Your one-stop source for computer help

  6. #6
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    No need

    Hey.

    No need to try both.

    That's Kill.


    Sorry, it's after midnight here in Beijing.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    so which 1 is the correct one?
    NXSupport - Your one-stop source for computer help

  8. #8
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    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

  9. #9
    Guest
    Kill "filename"
    is the right one.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Ok, thanks to all
    NXSupport - Your one-stop source for computer help

  11. #11
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604
    PS

    KillDoc is for killing a print job in code.

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks, I'll keep that in mind if I ever need it
    NXSupport - Your one-stop source for computer help

  13. #13
    Guest
    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

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    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
  •  



Click Here to Expand Forum to Full Width