|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThis article describes how to read information from a config file exactly like the app.config file, including information on linking in external files, using custom configuration section handlers, sections, and section groups. BackgroundI have looked at several articles that build everything from preference sections to simply building something that reads a section from XML that looks like the Using the codeThe code is used just like the string val =
CustomConfigurationSettings.ConfigurationSettings.AppSettings["myTestKey"];
This is the simplest way to use it. Using it this way assumes a config file named assemblyname.dll.config or executable.exe.config, really it just picks up the output file name for the assembly and adds .config to it. The file should be in the same directory as the assembly. It supports all the built-in classes in .NET that support the <appSettings file="filename.config">
<add key="test" value="myTest"/>
</appSettings>
If you don't want to use the //Include whatever file name that you want for the second parameter
NameValueCollection values = (NameValueCollection)
CustomConfigurationSettings.ConfigurationSettings.GetConfig("myconfigSection",
"myConfig.config");
string val = values["myTestKey"];
Points of InterestLoading the external file for the
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||