tags:

views:

4636

answers:

5

I found solutions for Windows Forms with AppDomain but what would be the equivalent for a WPF Application object?

A: 
String exePath = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
 string dir = Path.GetDirectoryName(exePath);

Try this!

ArsenMkrt
Not pretty, but works. Thanks :-)
Joey
+19  A: 
AppDomain.CurrentDomain.BaseDirectory

System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName)
Helen
Ah, thanks. Must have overlooked AppDomain somehow. I was looking for it, actually ...
Joey
+3  A: 

Here is another:

System.Reflection.Assembly.GetExecutingAssembly().Location

Regards.

Eddie Butt
A: 

use

System.IO.Directory.GetCurrentDirectory();

Pankaj Hirway
Navigate to an arbitrary path on the command line, start the application by entering its full path and watch what happens to this property.
Joey
A: 

You can also use the first argument of the command line arguments: String exePath = System.Environment.GetCommandLineArgs()[0]

Flip