|
-
April 1st, 1999, 06:21 AM
#1
how to delete directory and its content?
How can I delete the whole directory regardless whether it is empty or not? I've tried RemoveDirectory(), remove() function, but their all failed when there is file or subdirectory in the directory.
-
April 1st, 1999, 07:34 AM
#2
Re: how to delete directory and its content?
No Win32 API function can delete the whole directory ! You must implement this
by RemoveDirectory() and DeleteFile().
-
April 1st, 1999, 01:37 PM
#3
Re: how to delete directory and its content?
You can do a recursive search, finding and deleting all the contents of the directory before you attempt to delete the directory itself.
Alternatively, you can use SHFileOperation to delete the entire directory at once.
-
March 22nd, 2001, 07:43 AM
#4
Re: how to delete directory and its content?
The easiest way I found was to get my program to create a bat file on the fly that contains the following:
@Echo Off
rd [dir_to_be_deleted] /S /Q
I then call this bat file from my C++ program using CreateProcess(). Once the bat file has finished, I remove it (the bat file) from the location I created it on using remove(path_and_file). Therefore the directory and bat file are removed from the user's hard drive.
I've tried the recursive route, but trust me, this is much simpler!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|