How to create a new folder using boost when a folder with the same name already exists?

Viewed 25425

I am using boost::filesystem to create an empty folder (in Windows). Let say that the name of the folder that I want to create is New Folder. When I run the following program, a new folder with the required name is created, as expected. When the run the program for the second time, I want New Folder (2) to be created. Though it is an unreasonable expectation, that is what I want to achieve. Can someone guide me?

#include <boost/filesystem.hpp>
int main()
{
     boost::filesystem::path dstFolder = "New Folder";
     boost::filesystem::create_directory(dstFolder);
     return 0;
}

Expected output:

Expected output

2 Answers
Related