get directory from file path c++

前端 未结 11 1411
梦如初夏
梦如初夏 2020-12-13 14:45

What is the simplest way to get the directory that a file is in? I\'m using this to find the working directory.

string filename = \"C:\\MyDirectory\\MyFile.b         


        
11条回答
  •  一整个雨季
    2020-12-13 15:11

    Use the Boost.filesystem parent_path() function.

    Ex. argument c:/foo/bar => c:/foo

    More examples here : path decomposition table and tutorial here.

提交回复
热议问题