It is often useful to be able to determine the path where
the current executable resides. A simple way to do this using Visual Basic .NET
is to read the value of the StartUpPath property of the Application class. This can also be achieved by determining the
current working path or utilizing reflection to determine the code base
location of the currently executing assembly.

Example

In order to demonstrate finding the executable path, add the listbox control ListBox1 to the form and add the code in Listing A. (Note: You must use theSystem.Windows.Forms
namespace to use the technique in this example.) When you run the code, your
result will look like Figure 1.

In this example, I utilize the System.Windows.Forms namespace
and initially get the ExecutablePath
property of the Application class.
The value is displayed in ListBox1.
Then, I get the StartUpPath
property of the Application class and
also display it in ListBox1.