应用程序路径

应用程序路径

问题描述:

可能重复:
How can I get the application's path in .NET in a console app?应用程序路径

我怎样才能获得应用程序的路径? (文件夹中的可执行文件中)

+4

@Pranay:请不要乞求接受。这是该用户询问的第一个问题,[系统甚至不会让他们接受答案](http://meta.stackexchange.com/questions/38090/discourage-questions-being-marked-作为-回答中之一个小时或 - SO-的感-邮政/ 44099#44099)。我觉得我以前问过你。 – 2011-04-28 10:18:45

Determine the Executing Application's Path

path = System.IO.Path.GetDirectoryName( 
     System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); 

Brad Abrams site,你可能想看看这个代码:

Console.WriteLine (Environment.GetCommandLineArgs()[0]); 

或者,从评论中该链接:

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;