Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get program path in VB.NET?

Tags:

.net

vb.net

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

like image 815
Linda Avatar asked Feb 07 '10 06:02

Linda


2 Answers

Try this: My.Application.Info.DirectoryPath [MSDN]

This is using the My feature of VB.NET. This particular property is available for all non-web project types, since .NET Framework 2.0, including Console Apps as you require.

As long as you trust Microsoft to continue to keep this working correctly for all the above project types, this is simpler to use than accessing the other "more direct" solutions.

Dim appPath As String = My.Application.Info.DirectoryPath
like image 31
Mark Hurd Avatar answered Sep 20 '22 18:09

Mark Hurd


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()
like image 195
Nick Craver Avatar answered Sep 18 '22 18:09

Nick Craver