tags:

views:

234

answers:

2

How can I get runnig path of my application from app.xaml.cs itself?

A: 

You can just use the System.Environment.GetCommandLineArgs property to get the command line that started the application. Parse that with the System.IO.Path methods to extract just the executable's filename or full path.

var exeName = System.IO.Path.GetFileName(
    System.Environment.GetCommandLineArgs()[0]);
MessageBox.Show("This exe's filename is " + exeName);
Matt Hamilton
+4  A: 

You could try

Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)

AppDomain.CurrentDomain.BaseDirectory

and/or

Environment.CurrentDirectory
Mihai Lazar