#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    160
    Rep Power
    11

    VB 6: How do I delete a directory?


    Hello,

    I am new to visual basic 6.0 development...

    I need to delete a directory, however, I have one unique problem. The directory occasionally contains system files, and in this event, the "Kill" function won't work. And because the directory contains a file, I cannot delete the directory.

    The system file that is causing the problem is Thumbs.db.

    Does anyone know how I can delete the directory?

    Thanks!
    Crystal
  2. #2
  3. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    RmDir removes the folder. Kill should work. If it doesn't try using SetAttr on the thumbs.db file. If the system is using thumbs.db though and has it locked that won't work. I can't test any of this from an NT box though.

    Code:
    Sub FileFunctions()
        ' // Make a directory
        MkDir "c:\MyNewFolder"
        ' // Delete a directory
        RmDir "c:\MyNewFolder"
    End Sub
    But as you say the folder must be empty.

    Kill "c:\MyNewFolder\*.*" should clean it up.
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2004
    Posts
    160
    Rep Power
    11
    Unfortunately, I had already tried this and it did not work. The problem involves the thumbs.db file

    Originally Posted by medialint
    RmDir removes the folder. Kill should work. If it doesn't try using SetAttr on the thumbs.db file. If the system is using thumbs.db though and has it locked that won't work. I can't test any of this from an NT box though.

    Code:
    Sub FileFunctions()
        ' // Make a directory
        MkDir "c:\MyNewFolder"
        ' // Delete a directory
        RmDir "c:\MyNewFolder"
    End Sub
    But as you say the folder must be empty.

    Kill "c:\MyNewFolder\*.*" should clean it up.
  6. #4
  7. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    Huh, well if you tried using SetAttr before you killed, and killed all the files before attempting rmdir then I'm kinda surprised you had no luck.
    Last edited by medialint; September 6th, 2006 at 11:57 AM.
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss

IMN logo majestic logo threadwatch logo seochat tools logo