Configuration File Reader

Problem:

  • Lots of configuration things can potentially change, and command line arguments are out of the question.

Solution:

Sample Code:

// in the code
string mykey = System.Configuration.ConfigurationSettings.AppSettings ["Key1"];
 
// foobar.exe.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Key1" value="Kevin" />
</appSettings>
</configuration>

Note:

  • Apparently, this is now deprecated. Maybe should use ConfigurationManager API instead.

Related Links:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License