Question

I am using C#'s XML application settings for my Windows Form. Whenever I release a new version of the program, the user has to re-enter the settings because the settings will now be read from a new path.

The path looks like this:

%LOCALAPPDATA%\<program name>\<program name>._Url_<a random string>\<version>\user.config

What I want to be able to do is either have it so I can set the path of the settings myself so they do not get reset, is this possible? If so, how would I go about doing this?

Was it helpful?

Solution

Check the ApplicationSettingsBase.Upgrade metod

I found this on MSDN. It will read existing setting values from old version. I have tested with a helloword winforms app and my "Option1" setting was kept after version upgrade.

        Properties.Settings.Default.Upgrade();
        Properties.Settings.Default.Save();
        label1.Text = Properties.Settings.Default.Option1;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top