如何将工作目录设置为“解决方案目录"?在C ++中? [英] How do I set the working directory to the "solution directory" in c++?

查看:37
本文介绍了如何将工作目录设置为“解决方案目录"?在C ++中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将当前目录设置为解决方案目录/配置名称.我怎么做?我可以以某种方式使用全局变量吗?

I want to set the current directory to the solution diretory/configuration name. How do I do that? Can I use the global variables somehow?

我正在尝试读取文件,并且当前目录在代码中间更改.我想改回来.

I am trying to read a file and the current directory changes in the middle of the code. I want to change it back.

推荐答案

如果当前目录正在更改,则可能应在启动时将工作目录保存在某个变量中,您可以稍后访问该变量以将cwd设置在那里.至少这就是我对您的问题的理解.

If your current directory is changing, you should probably save your working directory at startup in some variable you can access later to set cwd back there. At least this is how I understand your question.

要获取cwd,请可能会有帮助.

For getting the cwd, this might help.

这篇关于如何将工作目录设置为“解决方案目录"?在C ++中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆