问题
Is it possible to create a custom configuration file (other than app.config) that can be processed by classes in the System.Configuration namespace?
I have seen a ton of articles that talk about custom sections (inside the app.config file) but I would like to make an entirely new config file.
Is there any decent documentation that covers this topic?
thanks
回答1:
You do not state what you want to achieve by having a separate file, but there are a couple of different things you can do.
If you want to "modularize" you configuration, you can break out certain config sections to separate files, using the configSource attribute:
// point out a file containing the connectionStrings config section
<connectionStrings configSource="connections.config"></connectionStrings>
You can also open a specific configuration file by calling ConfigurationManager.OpenExeConfiguration.
来源:https://stackoverflow.com/questions/1061999/adding-a-custom-configuration-file-in-c-sharp-application