JPJedi JPJedi - 2 months ago 4
Vb.net Question

Executable directory where application is running from?

I need to get the path (not the executable) where my application is running from:

System.AppDomain.CurrentDomain.BaseDirectory()


When I run the above statement with & "/images/image.jpg" on my local machine it works fine but when I install the application on another machine it says it cannot find the file and there is a lot of extra path information some.

I just need the directory of where the app is running. I am coding in VB.NET with Visual Studio 2008.

Thanks!

Answer
Dim strPath As String = System.IO.Path.GetDirectoryName( _
    System.Reflection.Assembly.GetExecutingAssembly().CodeBase)

Taken from HOW TO: Determine the Executing Application's Path (MSDN)

Comments