Results 1 to 8 of 8

Thread: Delete Folder with files and subfolders

  1. #1

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Post

    I need to delete a folder that has files in it and sub folders with files in them...etc...

    How can I delete the parent folder and all the subfolders and files in it without deleting the individual files first?

    ------------------
    Morgan
    [email protected]
    My Web Page

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    RmDir dir1

    ------------------
    smalig
    [email protected]
    smalig.tripod.com

  3. #3

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Post

    RmDir won't delete a directory with files in it...

    This Directory has anywhere from 20-50 subdirectories in it each with countless files in them...

    ------------------
    Morgan
    [email protected]
    My Web Page

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Try the FileSystemObject, eg.
    Code:
        Dim oFSO As Object
        Set oFSO = CreateObject("Scripting.FileSystemObject")
        oFSO.DeleteFolder "C:\Test", True

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  5. #5

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Post

    Ah Ha!! I had tried:
    oFSO.DeleteFolder "C:\Test"
    But it didn't work...

    Then I tried your
    oFSO.DeleteFolder "C:\Test", True
    and it worked...

    Thanks!!!

    ------------------
    Morgan
    [email protected]
    My Web Page

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Yes, the second parameter indicates where the files or folders in that folder should be removed.


    Regards,

    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  7. #7
    Member
    Join Date
    Jun 1999
    Posts
    38

    Post

    why not Kill(path) ?
    that would work wouldnt it?

  8. #8
    New Member
    Join Date
    Jan 2000
    Posts
    2

    Post

    Sorry Howard, the kill is for single files only

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