Search code examples
.netapp-configapplication-settings

.NET: How to manage application settings?


i've created some Application settings (i.e. not User) settings in my Visual Studio project:

enter image description here

This application will be running from a shared (i.e. read-only, network) location. How do i alter the application settings? e.g.

  • DefaultServer: fvirm001
  • DatabasePassword: QnV0IHNoZSdzIGluIGxvdmUgd2l0aCBzb21lb25lIGVsc2Uu

In the olden days (last Thursday) i would create a MyApp.ini file (in the same folder as MyApp.exe), and read the settings from there.

In the new XML .NET world i might change it to MyApp.xml. But then i remembered that .NET already has an XML file to store application settings. (e.g. the customer might want to manage the set of trace listeners in app.config).

How do i manage the <applicationSettings> in app.config?

enter image description here

Can i simply create an app.config file in the application directory, and .NET will use values as an override?

Microsoft's MSDN page on Managing Application Settings does not mention how to manage application settings.


Solution

  • You can change the values in the Settings designer window you have open. But yes, they're stored in the config file (ProgramExecutable.exe.config).

    Application Settings are not designed to be changed by the user, so there's no way to change them at runtime (unlike User settings, which can be reassigned and saved).