System.Configuration.ApplicationSettingsBase.Save Method

Stores the current values of the application settings properties.

Syntax

public override void Save ()

Remarks

The ApplicationSettingsBase.Save method writes the current value of each settings property to its associated data store. For each property, this method calls the SettingsProvider.SetPropertyValues(SettingsContext, SettingsPropertyValueCollection) method on the associated settings provider.

This method differs from the base class implementation in that it raises the ApplicationSettingsBase.SettingsSaving event before the values are written.

If the only settings defined are application-scoped settings, ApplicationSettingsBase.Save will have no effect and return no error if called with the default System.Configuration.LocalFileSettingsProvider. System.Configuration.LocalFileSettingsProvider only saves user-scoped settings.

Note:

There is no corresponding Load method because the values of application settings are automatically loaded during wrapper class initialization. In contrast, these values are not automatically saved when an application ends. Therefore, you must explicitly call the ApplicationSettingsBase.Save method to persist the current values of the application settings. This is typically performed in the System.Windows.Forms.Form.Closing event handler of the primary or containing System.Windows.Forms.Form.

Requirements

Namespace: System.Configuration
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0