Delete directory with files and sub folders

Hi,

I need to delete the directory with files and sub folders. If i use RemoveDirectory(), it will delete the empty directory only. Is any function available for deleting the directory with files & sub folders ? otherwise how can do this?


Thanks in advance
I don't think there is such a function. You will have to write it yourself.
You can use boost for this:

http://www.boost.org/doc/libs/1_51_0/libs/filesystem/doc/reference.html#remove_all

boost offers loads of usefull things
The algorithm goes something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
RemovePath( path )
    if FindFirstFile( path )
        do
           if (name == . || name == ..)
               continue;
           endif
           if (name is a file)
               delete name
           endif
           if (name is a directory)
               newpath = path + \ + name
               RemovePath( newpath )
           endif
        while FindNextFile != STOP
        delete path
    endif
end RemovePath
Last edited on
Topic archived. No new replies allowed.