c++boost-filesystem

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


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.


Solution

  • There is method parent_path, check the docs.