How to retrieve application settings when program installed to a new location
Posted on 2015-02-24
I have a VB.Net program, called (for instance) "MyProgram", that was installed to a folder in Program Files called, "MyProgram v. 1". This program has application settings that Windows stores in a folder called "MyProgram_Url_n4n5qrewg1zi5ilbibrsl21idmzcsdhw", which is located in the "AppData\Local" folder. In the program there is the following code:
If My.Settings.CallUpgrade Then
My.Settings.CallUpgrade = False
This code ensures that when I update my program, say from v. 188.8.131.52 to v. 184.108.40.206, that the application settings from the previous version. This has worked very well and I have upgraded my application numerous times without a problem. And each new version adds a new folder to the application data folder with the version number as the folder name containing a "user.config" file.
However, I now want to do a major upgrade to v. 2.0, and want to change the location of installation of the program (in Program Files) from "MyProgram v. 1" to simply, "MyProgram", since it is silly to keep the version number in the folder name. However, when the program is installed, there are now two folders in Program Files: "MyProgram v. 1" and "MyProgram", and there is now a new folder in the "AppData\Local" folder, "MyProgram_Url_w1x02urygryc3nq3z4ajs5h3r3rc443k", which only contains a folder named "220.127.116.11". It does not have folders for the older versions, because those version folders are contained in the application data folder created for verison 18.104.22.168 of the program.
So it appears that once I change the installation location of the program, Windows treats it as a new application and creates a new place to store the application data. My question is if there is any way to change this and/or have version 2.0 of "MyProgram" be able to find the previous version's config file to use as a base for its settings? Thank you.