Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get the installed path of a vb.net application

I'm nearly ready to distribute my vb.net application. I have several picturebox files which are loaded currently from c:/temp

I need to change this directory to one that will be OK to use when the user installs it to their PC.

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

Or... would it be better for me to use mypictures within the mydocuments structure? I'd rather keep all the image files created in a folder which is more hidden from the user (by hidden I mean not cluttering up their own image folders!)

I've tried searching for this, but I seem to get varying results with no real answers... (possibly searching for the wrong thing!)

like image 688
Matt Facer Avatar asked Dec 29 '22 17:12

Matt Facer


1 Answers

You can get the ExecutablePath with:

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

Then you'll know where the application is residing.
As for where to save your images a common location is the AppData folder.
You can get it like this:

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

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

like image 132
Sani Singh Huttunen Avatar answered Dec 31 '22 07:12

Sani Singh Huttunen