How to delete a folder in C++?

user88240 picture user88240 · Apr 9, 2009 · Viewed 120.4k times · Source

How can I delete a folder using C++?

If no cross-platform way exists, then how to do it for the most-popular OSes - Windows, Linux, Mac, iOS, Android? Would a POSIX solution work for all of them?

Answer

Edouard A. picture Edouard A. · Apr 9, 2009

I strongly advise to use Boost.FileSystem.

http://www.boost.org/doc/libs/1_38_0/libs/filesystem/doc/index.htm

In your case that would be

boost::filesystem::remove_all(yourPath)