How to save application level settings in windows application
Posted on 12/22/2006 9:00:22
in #Windows Programming
Hi
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.
This means that if we only change the setting value then we will get the changed setting value, till the application is running. But once the machine restarts the setting values will change to the default value. To get the changed session value even after the application has restarted we need to save the application setting by calling the save method.
Hope this helps Thanks Vikram
|
Posted on 1/7/2008 11:23:25
This is fine for user specific application settings.
What is the solution if I want to make application specific settings for all the users and if any of the user updates the settings should be available for other users?
|