How do I find the current directory?(如何找到当前目录?)
问题描述
我正在尝试读取我之前成功读取的文件.我正在通过图书馆阅读它,并将其按原样发送到图书馆(即myfile.txt").我知道该文件是从工作/当前目录中读取的.
I am trying to read a file which I read previously successfully. I am reading it through a library, and I am sending it as-is to the library (i.e. "myfile.txt"). I know that the file is read from the working/current directory.
我怀疑当前/工作目录以某种方式改变了.我如何检查当前/工作目录是什么?
I suspect that the current/working directory has changed somehow. How do i check what is the current/working directory?
推荐答案
既然你添加了 Visual-c++ 标签,我将建议使用标准的 windows 函数来做这件事.GetCurrentDirectory
Since you added the visual-c++ tag I'm going to suggest the standard windows function to do it. GetCurrentDirectory
用法:
TCHAR pwd[MAX_PATH];
GetCurrentDirectory(MAX_PATH,pwd);
MessageBox(NULL,pwd,pwd,0);
这篇关于如何找到当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何找到当前目录?
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- C++ 协变模板 2021-01-01
- 近似搜索的工作原理 2021-01-01
- 从python回调到c++的选项 2022-11-16
- Stroustrup 的 Simple_window.h 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01