如何获得同一项目的当前环境 [英] How can get current Environment of the same project
本文介绍了如何获得同一项目的当前环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生,我想知道如何获得当前的项目环境.实际上我正在使用下面的代码来获取,但这是返回D:目录.我在E:驱动器中的项目应该返回E:dreive.所以请先生帮我.
sir i would like to know how can get Current project Environment. actually i am using this below code to get but this is return D: directory. my project in E: Drive it should be return E: dreive. so plzzz help me sir.
string filename = Environment.CurrentDirectory.ToString();
推荐答案
要获取当前正在运行的应用程序的文件夹:
To get the currently running application''s folder:
string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
获取当前工作目录:
To get the current working directory:
string path = Environment.CurrentDirectory;
应用程序文件夹和工作"文件夹不一定总是相同.
The application folder and the "working" folder are not always necessarily the same.
first:
CurrentDirectory是一个字符串,因此您可以删除ToString().
进一步:阅读 http://msdn.microsoft.com/en-us/library/system .environment.currentdirectory.aspx [ ^ ]
first:
CurrentDirectory is a string so you can remove ToString().
further: read http://msdn.microsoft.com/en-us/library/system.environment.currentdirectory.aspx[^]
这篇关于如何获得同一项目的当前环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文