Tuesday, September 23, 2008

How to get the path to my running EXE and DLL?

If you want to get the path of the running EXE of your project you might need to use this code.


The Application class has a static member ExecutablePath that has this information.

string appPath = Application.ExecutablePath;  

Howerver if you want to get the path of the executing assembly here is the code.


Also, there are a number of ways to get the app.path in VB.NET. This particular method works for VB.NET (including windows forms applications and .dlls) and ASP.NET. Unlike App.Path in VB6, this includes the the "\" at the end of the value.

Declarations: none
Public Function App_Path() As String         
Return System.AppDomain.CurrentDomain.BaseDirectory()
End Function