开发者

Find Working Project Directory in C#.Net

开发者 https://www.devze.com 2023-02-07 15:58 出处:网络
I have used Directory.getCurrentDirectory(); its giving only C:\\Windows\\SysWOW64 but i need to get the visual studio default project folder how can i get that ?

I have used Directory.getCurrentDirectory();

its giving only C:\Windows\SysWOW64

but i need to get the visual studio default project folder how can i get that ?

ex:C:\Users\knallasi\Documents\Visual Studio 2010\Projects\SampleApp

how do we find that above project location ?

Thanks in 开发者_如何学CAdvance


I'm not sure about the PROJECT directory, but the directory of the executing assembly can be found by using

string currentAssemblyDirectoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

usually, if you're executing in Visual Studio, the project directory is up two levels, you you could trim "bin\release| or "bin\debug" of that string to get the project directory, but that's a bit of a hack. I'm not sure there is a way to get the project directory from code.


After lots of searching I found the "dirty hack" solution for accessing things like $(ProjectDir) from within your code.

What's an easy way to access prebuild macros such as $(SolutionDir) and $(DevEnvDir) from code in C#?

0

精彩评论

暂无评论...
验证码 换一张
取 消