在C#.Net中查找工作项目目录

在C#.Net中查找工作项目目录,c#,.net,directory,C#,.net,Directory,我使用了Directory.getCurrentDirectory() 它只提供C:\Windows\SysWOW64 但是我需要获取VisualStudio默认项目文件夹,我如何才能获取它 示例:C:\Users\knallasi\Documents\Visual Studio 2010\Projects\SampleApp 我们如何找到上述项目位置 提前感谢我不确定项目目录,但是可以使用 string currentAssemblyDirectoryName = Path.GetDirect

我使用了Directory.getCurrentDirectory()

它只提供C:\Windows\SysWOW64

但是我需要获取VisualStudio默认项目文件夹,我如何才能获取它

示例:C:\Users\knallasi\Documents\Visual Studio 2010\Projects\SampleApp

我们如何找到上述项目位置


提前感谢

我不确定项目目录,但是可以使用

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

通常,如果您在Visual Studio中执行,项目目录将上升两级,您可以修剪该字符串的“bin\release”或“bin\debug”以获取项目目录,但这有点麻烦。我不确定是否有办法从代码中获取项目目录。

经过大量搜索后,我发现了“肮脏的麻烦”“从代码中访问$(ProjectDir)等内容的解决方案


它是什么类型的应用程序?我在问贝克。我想知道您的流程上下文是否可能是一个服务(可能像iis应用程序池)gabriel,它的XBAP应用程序wpf。谢谢david,我也这么认为,但修剪“bin\debug”是我们唯一想做的事情!System.Reflection.Assembly,以防您尚未“使用”它