Get the installed vb.net application path

I am almost ready to distribute the vb.net application. I have several image files that are currently being downloaded from c: / temp

I need to change this directory to one that will be fine when the user installs it on their computer.

My question is: how can I do this? Is there a way to get the installation path and then use it in the code as a variable? eg: myInstalledPath & "/xxx.jpg"

Or ... would it be better if I used mypictures in the mydocuments structure? I would prefer to keep all image files created in a folder more hidden from the user (hidden I mean not to clutter up your own image folders!)

I tried looking for this, but I seem to get different results without real answers ... (maybe I was looking for the wrong thing!)

+4
source share
2 answers

You can get ExecutablePath with:

 Dim appPath As String = Path.GetDirectoryName(Application.ExecutablePath) 

Then you will find out where the application is located.
As for where to save your images, the general location is the AppData folder.
You can do it as follows:

 Dim appDataPath As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) 

The AppData folder is by default a hidden folder that meets your requirements.

+9
source

You can get the string path st setup time

string path = Path.GetDirectoryName(Application.ExecutablePath);

and get the software installation path after that use the resource folder to access it

0
source

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


All Articles