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!)
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.
精彩评论