Results 1 to 6 of 6

Thread: Deleting a folder and all of it's contents

  1. #1

    Thread Starter
    Lively Member Flustor's Avatar
    Join Date
    Sep 2001
    Location
    A small hole in Birmingham
    Posts
    76

    Question Deleting a folder and all of it's contents

    How do I do this?

    I know that I could loop through each and every folder deleting each file using the Kill method, but this would be a pain. Is there any way to do this better?

    Flustor

  2. #2
    Matthew Gates
    Guest
    You could always use Deltree, which I believe deletes every file in every folder (subdirectories).


    VB Code:
    1. Shell "command.com Deltree /Y C:\MyFolder\Stuff\MoreStuff\*.*

  3. #3
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    You can use the File System Object and I think that it will delete the folder along with the files.

  4. #4

    Thread Starter
    Lively Member Flustor's Avatar
    Join Date
    Sep 2001
    Location
    A small hole in Birmingham
    Posts
    76

    Cool

    Excellent!! I'll give that a try.

    thanx!

  5. #5

    Thread Starter
    Lively Member Flustor's Avatar
    Join Date
    Sep 2001
    Location
    A small hole in Birmingham
    Posts
    76
    I've just found that Microsoft (in their infinate wisdem) have dumped Deltree. One of my favorates in the days of Dos 6.

    So that shell command doesn't work! Good idea though (which I'll be using in future).. any others?

  6. #6
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    VB Code:
    1. Dim fso As New FileSystemObject
    2.  
    3. If fso.FolderExists Then fso.DeleteFolder ("C:\Temp")

    You need the Microsoft Scripting Runtime in your references.
    You could technically do a recursive kill feature and kill *.* in every sub directory then kill each subdirectory then the directory you wanted to kill, but this is much more convenient.
    -Excalibur

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