-3

How can we figure out the filesystem location of the running application?

Pierre-Luc Pineault
  • 8,363
  • 6
  • 38
  • 53
Travis Banger
  • 677
  • 1
  • 5
  • 18
  • Are you looking for [`Directory.GetCurrentDirectory`](http://msdn.microsoft.com/en-us/library/system.io.directory.getcurrentdirectory(v=vs.110).aspx) – Harrison Jan 06 '14 at 21:41
  • 1
    That would depend on the type of application: console, winforms, wpf, asp.net, windows phone, ... I hope you realize that the fact that you tagged your question with C# is pretty meaningless in this context. – Darin Dimitrov Jan 06 '14 at 21:41
  • application.info.path and many other properties will help you – Ali.Rashidi Jan 06 '14 at 21:42
  • 3
    ... or [this](http://stackoverflow.com/questions/6041332/best-way-to-get-application-folder-path) or [this](http://stackoverflow.com/questions/7025269/c-sharp-executable-executing-directory) or [this](http://stackoverflow.com/questions/5606747/how-to-get-application-path) or [this](http://stackoverflow.com/questions/362790/what-is-the-best-way-to-determine-application-root-directory) or [this](http://stackoverflow.com/questions/881251/how-to-get-the-path-of-appwithout-app-exe) ... if the site suggests to check whether your question has been asked before, **please do so**. – O. R. Mapper Jan 06 '14 at 21:44

2 Answers2

2

If you work on Console use this

AppDomain.CurrentDomain.BaseDirectory

or on Windows Forms use

Application.StartupPath 
Omer K
  • 5,196
  • 10
  • 53
  • 73
  • 3
    @TravisBanger: Your question does not give any indication of that. You should add the appropriate tags. Pro tip: With the WPF reference added, your question is a duplicate of [this question](http://stackoverflow.com/questions/938421/getting-the-applications-directory-from-a-wpf-application) and [that one](http://stackoverflow.com/questions/10926506/how-to-get-current-application-path-in-wpf). – O. R. Mapper Jan 06 '14 at 21:47
0

Environment.GetCommandLineArgs()[0];

alu
  • 719
  • 7
  • 20