ConfigurationManager::AppSettings Property
.NET Framework (current version)
Gets the AppSettingsSection data for the current application's default configuration.
Assembly: System.Configuration (in System.Configuration.dll)
Property Value
Type: System.Collections.Specialized::NameValueCollection^Returns a NameValueCollection object that contains the contents of the AppSettingsSection object for the current application's default configuration.
| Exception | Condition |
|---|---|
| ConfigurationErrorsException | Could not retrieve a NameValueCollection object with the application settings data. |
A AppSettingsSection object contains the contents of the configuration file's appSettings section.
The first example shows a simple console application that reads application settings, adds a new setting, and updates an existing setting.
The previous example assumes your project has an App.config file as shown below.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <appSettings> <add key="Setting1" value="May 5, 2014"/> <add key="Setting2" value="May 6, 2014"/> </appSettings> </configuration>
.NET Framework
Available since 2.0
Available since 2.0
Show: