小编Nil*_*nge的帖子

如何在c ++中从std :: ifstream获取文件路径

我使用打开文件std::ifstream.

我可以使用相对路径(file.txt)或绝对路径(C:\test\file.txt)打开文件.

当我传递一个字符串作为文件名时,我不知道它是相对路径还是绝对路径.

任何人都可以告诉我如何在文件成功打开后获取绝对路径 std::ifstream

例如:

std::ifstream file(strFile); // strFile is "file.txt" or "C:\test\file.txt"
Run Code Online (Sandbox Code Playgroud)

我希望在文件成功打开后获取绝对路径.

谢谢,

c++ file absolute-path

24
推荐指数
2
解决办法
3万
查看次数

标签 统计

absolute-path ×1

c++ ×1

file ×1