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);
这篇关于如何找到当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何找到当前目录?
基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
