views:

61

answers:

3

Hi Friends how can i find the location of execute of my application in WPF (C# or vb.net) ? i used this code on windows forms . Application.ExecutablePath.ToString()); But IN WPF i had this message from Visual studio that : system.window.application does not contain definition for ExecutablePath. tnx for ur attentions :)

+2  A: 

System.Reflection.Assembly.GetExecutingAssembly().Location should work.

Blorgbeard
thank u!worked
shaahin
+2  A: 

Several alternatives:

Directory.GetParent(Assembly.GetExecutingAssembly().Location)

System.AppDomain.CurrentDomain.BaseDirectory

Only in VB:

My.Application.Info.DirectoryPath
Konrad Rudolph
thanks for ur attentionworked
shaahin
A: 

In C#

Application.ExecutablePath

Should work. It gives you the path of your executable file. Be aware though: if you debug your application, then the path it returns would be project/bin/debug/ .

Igor