How to remove a directory along with it's contents?

How to remove a directory along with its contents in C++11? I thought rmdir() removes directory along with its contents but it removes only empty directories.
Is there any function in C++11?
In C++11, there is no standard way of deleting directories.

If you've got a more modern compiler, you can use remove_all ; https://en.cppreference.com/w/cpp/filesystem/remove
I have TDM-GCC 4.9.2 64 Bit release. I will do in the non standard way. Tell me how to do this.
Last edited on
What OS are you using? You will either have to use a library, or use OS API directly.
Windows 10 v1809 64 bit. I am all new to this.
Last edited on
you can do it with commands.
del /s deletes all the files under the path. (you don't need this -- it leaves the folder structure).
rmdir /s /q deletes all the folders after that. (this zaps the files too).

winapi is better than os system calls if its a windows program. If its a console program for your own use, system is fine. If you just want this and nothing else, a batch file is fine or type in console (batch just lets you double click without opening a console for things you do frequently).
Last edited on
Topic archived. No new replies allowed.