2011-04-28 148 views
2

可能重複:
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

回答

2

Brad Abrams site,你可能想看看這個代碼:

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

或者,從評論中該鏈接:

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