Label Cloud

Thursday, May 10, 2007

Upgrading application settings

.NET 2.0 has a very nice support for storing custom application settings. It provides a read-only access to the application level settings and read-write access to the user-level settings. For more information check out

One of the bugs I had to deal with in QueryExPlus is that whenever a new version of the application was released, the settings would get reset to their defaults. The culprit is that settings are stored in the C:\Documents and Settings\\Local Settings\Application Data\\_Url_\\user.config

The location includes the location hash and the version of the executable. The code to keep the old settings is pretty simple.

Add a user level setting called First_Run. Make it boolean and set the default to be False

If this is a first run of the application version, call Upgrade() function, set the First_Run setting so you do not do it again and save the settings.

if (QueryExPlus.Properties.Settings.Default.IsFirstRun)



Settings.Default.IsFirstRun = false;


MessageBox.Show("Settings Upgraded");



No comments:

Directory of Computers/Tech Blogs