Question

I have a WPF application that uses user settings to store the users preferences and I use the Wix installer to install the application. When the application gets installed, the default config file is placed under the install location, for example C:\Program Files[CompanyName][ApplicationName]. When a user makes changes to their preferences in the application, these preferences are saved out to the users AppData folder, an example of this path might be

C:\Users[Username]\AppData\Local[ApplicationName][ApplicationName].exe_Url_pduhkwydh2kyq5nkqnr5jbnuaznm\1.1.0.0\user.config

Now, if I am upgrading the application to version 1.2.0.0, the application now defaults back to the default config file and when the user makes changes to their preferences again, a new folder is created this time being 1.2.0.0\user.config.

How can I preserve the user.config when upgrading the application? I don't know the location of the user.config file during install or where the new user.config will be created. Is there a better way of storing user settings?

Was it helpful?

Solution

This is an application issue, not an installer issue. The application should perform a settings upgrade by calling Upgrade.

To determine if an upgrade is required, create a user setting saying it is and then change it after the upgrade.

if (Properties.Settings.Default.IsFirstRun)
{
    Properties.Settings.Default.Upgrade();
    Properties.Settings.Default.IsFirstRun = false;
    Properties.Settings.Default.Save();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top