4

Possible Duplicate:
How can I get the application's path in .NET in a console app?

How can I get application path? (folder the executable is in)

Community
  • 1
  • 1
Stephanie
  • 77
  • 1
  • 6
  • 4
    @Pranay: Please stop begging for accepts. This is the first question this user has asked, and the [system isn't even going to let them accept an answer yet](http://meta.stackexchange.com/questions/38090/discourage-questions-being-marked-as-answered-within-an-hour-or-so-of-being-poste/44099#44099). I feel like I've asked you this before. – Cody Gray - on strike Apr 28 '11 at 10:18

2 Answers2

2

Determine the Executing Application's Path

   path = System.IO.Path.GetDirectoryName( 
      System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
2

From Brad Abrams site, you might want to look at this code:

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

Or, from comments in that link:

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; 
Grant Thomas
  • 44,454
  • 10
  • 85
  • 129