|
-
June 6th, 1999, 03:53 PM
#1
Implementing RemoveDirectory to handle non empty directories
Hi,
I needed to write a routine to delete a directory (even if it contained files and directories) which the Win32 API couldn't do. I digged up a recursive directory walker class that I had which supports bottom up recursion and used : eleteFile and ::RemoveDirectory on the walk back up the tree.
The algorithm is correct, but sometimes the RemoveDirectory call is returning DIRECTORY_NOT_EMPTY.
If I press refresh on explorer, I can visually see that the directory isn't empty.
If I insert a Sleep command within the tree walk, the directories all delete okay.
I've tried adding _flushall commands but that doesn't seem to have any effect.
Anyway, as I needed the algorithm for work, I sorted it using a brute force algorithm (i.e. running the recursion a number of times until all
the directories and files are deleted).
But I'd like to know why the RemoveDirectory sometimes returns DIRECTORY_NOT_EMPTY (probably because of caching) and how to flush the cache (or whatever is needed).
Thanks
Rob.
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
|