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!
You can write the following:
Taken from HOW TO: Determine the Executing Application's Path (MSDN)
You could use the static StartupPath property of the Application class.
I needed to know this and came here, before I remembered the Environment class.
In case anyone else had this issue, just use this:
Environment.CurrentDirectory
.Example:
When run from Visual Studio in debug mode yeilds:
This is the exact behaviour I needed, and its simple and straightforward enough.
This is the first post on google so I thought I'd post different ways that are available and how they compare. Unfortunately I can't figure out how to create a table here, so it's an image. The code for each is below the image using fully qualified names.