Getting the location of the installed vb.net application

I published the application on vb.net. the user will be able to install the application anywhere they choose on the computer (or perhaps not anywhere they choose, but wherever it is by default). How can I programmatically get the place where the user installed the application? another word i need the app to find out where it works from. How did I find this?

+3
source share
6 answers

At runtime, you can use:

Application.StartupPath
+7
source
Application.ExecutablePath 

which will tell you where your .exe is located. Hope this helps.

+5

If your application is a Windows Forms application, you can use a static application class, as others have noted. For other uses, use reflection:

Dim a = System.Reflection.Assembly.GetEntryAssembly()
Dim location = a.Location

I had to do it the other day, it works fine.

+4
source

Like this:

Shared ReadOnly AppDirectory As String = _
     Path.GetDirectoryName(New Uri(GetType(Program).Assembly.CodeBase).LocalPath)
+2
source

If you put this code in your exe, it will give you the path to exe.

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
+2
source

Source: https://habr.com/ru/post/1740498/


All Articles