Sunday, July 5, 2009

Find the executable path of current application

There are two ways to find the path the current running application.


1. Using Application.ExecutablePath

2. System.Reflection.Assembly.GetExecutingAssembly()

Prerequisties:

Import the System.Reflection name space in the top of the windows Form

Example:

[CODE]

Imports System.Reflection

Public Class Form1

....

Private Sub FindPathOfExe()

Dim appPath as String

'Method 1

appPath = Application.ExecutablePath

Debug.Print "Application path: " & appPath

'Method 2
appPath = System.Reflection.Assembly.GetExecutingAssembly().Location


Debug.Print "Application path: " & appPath


End Sub

End Class

[/CODE]

No comments:

Post a Comment