Here in my project I have two application configuration files called app.config and accessLevel.config. Now using the OpenExeConfiguration I was able to access the app.config.exe file but not the accessLevel.config. Please help on this.
The main reason I have 2 config files is to show the difference and make the code simple.
I need to read the values from the accessLevel.config in my C# code.
Tried the below code but no use:
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.File = "App2.config";
See here.
Put this in your
App.config:And then have another file called
accessLevel.configlike this:And then you can access your config values in code like this:
Make sure that
accessLevel.configis set to copy to the output directory (right click the file in Visual Studio -> Properties -> Copy To Output Directory -> Copy if Newer).