c# – accessig application configuration file using ConfigurationManager

By | 27. March 2017

Using configuration file is pretty straightforward. First  add to your application references Assembly System.Configuration. ConfigurationManager provides access to configuration files for client applications,

It makes sense to encapsulate configuration settings read and write to special methods.


To add or update use AddUpdateAppSettings:

For read use ReadSetting. In this sample we provide also default values so in case of missing configuration the application still works in development environment:

Keep in mind that if you run your application from Visual Studio the configuration file accessed and changed is YourApplicationName.vshost.exe.Config residing in \bin\Debug\ directory.

Both YourApplicationName.vshost.exe.Config and YourApplicationName.exe.config are copied do this directory from App.config usually located in project root directory. So if you want to have permanent configuration settings the App.config file must be amended.


Leave a Reply