Extract the parent folder of a directory using boost::filesystem

James Franco picture James Franco · Aug 14, 2015 · Viewed 9k times · Source

Suppose I have the following folder

std::string m("C:\MyFolderA\MyFolderB\MyFolderC");
boost::filesystem::path p(m);

Is there anyway for me to extract the parent of this folder. I want to get the string MyFolderB. from the above path.

Answer

Andrey picture Andrey · Aug 14, 2015

There is method parent_path, check the docs.