get directory from file path c++

前端 未结 11 1424
梦如初夏
梦如初夏 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 14:56

    This is proper winapi solution:

    CString csFolder = _T("c:\temp\file.ext");
    PathRemoveFileSpec(csFolder.GetBuffer(0));
    csFolder.ReleaseBuffer(-1);
    

提交回复
热议问题