tags:

views:

41

answers:

3

How can I get the absolute path of program I'm running?

+3  A: 

For that you can use the Application object.

Startup path, just the folder, use Application.StartupPath()

Dim appPath As String = Application.StartupPath()

Full .exe path, including the program.exe name on the end:, use Application.ExecutablePath()

Dim exePath As String = Application.ExecutablePath()
Nick Craver
does not allow me application. Is this in a namespace that I need to import? if so which?
Linda
It's in System.Windows.Forms
Matthew Flaschen
I am using a console app
Linda
+1  A: 

For a console application you can use System.Reflection.Assembly.GetExecutingAssembly().Location as long as the call is made within the code of the console app itself, if you call this from within another dll or plugin this will return the location of that DLL and not the executable.

lee-m
A: 

I use:

Imports System.IO
Dim strPath as String=Directory.GetCurrentDirectory
Corey B