Getting a directory name from a filename January 9, 2023 by Tarik Using Boost.Filesystem: boost::filesystem::path p("C:\\folder\\foo.txt"); boost::filesystem::path dir = p.parent_path();