how to empty a folder?

Discussion in 'C#' started by bclassic, May 17, 2008.

  1. #1
    A-folder has several folders under.
    I want delete those folders all under the A-folder.
    I want to keep the A-folder alive but shall be an empty folder.
    How to do it?

    I use fso.DeleteFolder(Path) but this way kills A-folder.
     
    bclassic, May 17, 2008 IP
  2. bclassic

    bclassic Peon

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    But by this way you have to goto CP and setup the folder permission again.
    I donot want to go to CP to setup permission again.
    Any other way?
     
    bclassic, May 17, 2008 IP
  3. nubsii

    nubsii Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can iterate through the contents of the folder-A and delete everything. This post is a few days old, if you are still looking for a solution I have some code that does something very similar (the opposite, expands a folder structure outwards like a tree), I'll find it if you still need it.

    Also do you only want to delete the folders under folder-A? or also any files that are in the root of folder-A as well?
     
    nubsii, May 22, 2008 IP
  4. bclassic

    bclassic Peon

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Someone sent PM to me.
    Problem solved
     
    bclassic, Jun 8, 2008 IP