Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I saw that I can use RemoveDirectory but I read that I can use it for empty directory..and I don't find a function that I can use.

What I have tried:

I tried to search on internet, I found only RemoveDirectory
Posted

Well, you obviously didn't look hard enough. From the documentation:
To recursively delete the files in a directory, use the SHFileOperation[^] function.

Alternatively, as in the second search result:
If you need to remove a non-empty directory, you do a depth-first traversal of the directory structure. As you traverse an individual directory, you erase all the files it contains. If it contains any sub-directories, you traverse into them, deleting their contents then deleting the (now empty) directory. Lather, rinse, repeat.
 
Share this answer
 
Comments
CPallini 4-Mar-24 7:16am    
5.
0x01AA 4-Mar-24 7:40am    
Would be interesting wheter MoveFileEx("c:\ToMove", "NUL", ...) also works :)
One small addition to Richard's post - here is a wrapper class around the ShFileOperation function : CShellFileOp - Wrapper for SHFileOperation[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900