Saving Application settings in a Windows Application

Many a times in the windows application when you create some settings, we ned to save the settings so that it can be retrieved and used when the user starts the application again. In Dot net this can be done very easily.

You need to save these settings in the Application settings. The scope of these setting should be user and not application. Remember the Settings with the scope of Application are readonly and hence these cannot be changed in the code.

Now to retrieve the settings use the following code

Properties.Settings.Default["SettingName"].ToString();

To change the settings for the user you need to

Properties.Settings.Default ["SettingName"] = “Value”;
Properties.Settings.Default.Save();

The setting is changed by setting the property value. But if you do not save the setting the changed setting will not be available next the application restart.

Leave a Comment