Visual Studio helps manage user and application settings. Using this approach has these benefits over using the appSettings
section of the configuration file.
web.config
for Web sites and Web applications, and app.config, renamed as assembly.exe.config, where assembly is the name of the executable. User settings (not used by Web projects) are stored in a user.config
file in the user’s Application Data folder (which varies with the operating system version).In most project types, the Project Properties Designer has a Settings tab which is the starting point for creating custom application and user settings. Initially, the Settings tab will be blank, with a single link to create a default settings file. Clicking the link results in these changes:
app.config
or web.config
) does not exist for the project, one will be created.Settings.settings
item is added under the Properties special folder. Opening this item will open the Settings tab.Properties
folder in the project folder. This new file is named Settings.Designer.__
(.cs, .vb, etc.), and the class is named Settings
. The class is code-generated, so it should not be edited, but the class is a partial class, so you can extend the class by putting additional members in a separate file. Furthermore, the class is implemented using the Singleton Pattern, exposing the singleton instance with the property named Default
.As you add each new entry to the Settings tab, Visual Studio does these two things: