I've got a Winforms app that has quite a few settings (.settings file). These are saved (as far as I can tell) in C:\Users\[User's username]\AppData\Local\[My program name]\[Build or something]\1.0.0.0\user.config but whenever I make a new build and a user runs that version, it makes a new [Build or something] folder and starts over with a "fresh set" of settings. What is the best practice for rolling over the settings from a previous version?
(Some settings I want to be "brand new" every time a new version is run and some settings I want to be copied from the last version)
I am using method described in this post (it says Clickonce but it is also applicable to other types of apps): https://blogs.msdn.microsoft.com/rprabhu/2005/06/29/client-settings-faq/
Q: Okay, but how do I know when to call Upgrade?
A: Good question. In Clickonce, when you install a new version of your application, ApplicationSettingsBase will detect it and automatically upgrade settings for you at the point settings are loaded. In non-Clickonce cases, there is no automatic upgrade – you have to call Upgrade yourself. Here is one idea for determining when to call Upgrade:
Have a boolean setting called CallUpgrade and give it a default value of true. When your app starts up, you can do something like:
This will ensure that Upgrade() is called only the first time the application runs after a new version is deployed.