[c#] get path for my .exe

how can I get my .exe path because if I copy my .exe I can get my new path ?

This question is related to c#

The answer is


in visualstudio 2008 you could use this code :

   var _assembly = System.Reflection.Assembly
               .GetExecutingAssembly().GetName().CodeBase;

   var _path = System.IO.Path.GetDirectoryName(_assembly) ;

In a Windows Forms project:

For the full path (filename included): string exePath = Application.ExecutablePath;
For the path only: string appPath = Application.StartupPath;


In addition:

AppDomain.CurrentDomain.BaseDirectory
Assembly.GetEntryAssembly().Location