I created a CLI application which actually uses the standard config app.Config file.
In this file I put some subsections, like
<typicsTable>
<mainSettings>
<add key="sheetNumber" value="1"/>
<add key="firstDataRow" value="2"/>
</mainSettings>
</typicsTable>
I actually read these settings with
NameValueCollection TypicsConversionTableSettings = (NameValueCollection)ConfigurationManager.GetSection("typicsTable/mainSettings");
int ctSheetNumber = Int32.Parse(TypicsConversionTableSettings["sheetNumber"]);
int ctFirstDataRow = Int32.Parse(TypicsConversionTableSettings["firstDataRow"]);
Everything works fine in this way.
What I want to do now is
1) I want different config files with custom names (i.e. test1.config , test2.config) and take via CLI the right config file;
2) switch to a less ".net config file", and take data from a standard XML file.
I'm now focusing on the point 1, I tried different attempts, I used
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = @"C:\folderTest\conf1.config";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
But I absolutely don't get how to read sections AND subsections in the file. How can I do that?
