<appSettings> element for <configuration>

Contains custom application settings. This is a predefined configuration section provided by the .NET Framework.



  <!-- Elements to add, clear, or remove configuration settings -->


file Optional attribute.

Specifies a relative path to an external file containing custom application configuration settings. The specified file contains the same kind of settings that are specified in the <add>, <remove>, and <clear> elements and uses the same key/value pair format as those elements.

The path specified is relative to the main configuration file. For a Windows Forms application, this is the binary folder (such as /bin/debug), not the location of the application configuration file. For Web Forms applications, the path is relative to the application root, where the web.config file is located.

The runtime ignores the attribute if the specified file can't be found.

Parent element

<configuration> Element The root element in every configuration file used by the common language runtime and .NET Framework applications.

Child elements

<add> Adds a custom application setting.
<clear> Clears all previously defined application settings.
<remove> Removes a previously defined application setting.


The <appSettings> element stores custom application configuration information, such as database connection strings, file paths, XML Web service URLs, or any other custom configuration information for an application. The key/value pairs specified in the <appSettings> element are accessed in code using the ConfigurationSettings class.

You can use the file attribute in the <appSettings> element of the Web.config and application configuration files. This attribute specifies a configuration file that provides additional settings or overrides the settings specified in the <appSettings> element. The file attribute can be used in source control team development scenarios, such as when a user wants to override the project settings specified in an application configuration file.

Configuration files specified by the file attribute must have a root node of <appSettings> rather than <configuration>.


The following example shows an external application settings file (custom.config) that defines a custom application setting:

<?xml version="1.0" encoding="utf-8" ?>
  <add key="MyCustomSetting" value="MyCustomSettingValue" />

The following example shows an application configuration file that consumes the setting in the external settings file and sets an application setting of its own:

  <appSettings file="custom.config">
    <add key="ApplicationName" value="MyApplication" />

Configuration file

This element can be used in the application configuration file, machine configuration file (Machine.config), and Web.config files that are not at the application directory level.

See also