deepak
deepak

Reputation: 1033

Adding a Custom Configuration file in C# application

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

Upvotes: 2

Views: 8024

Answers (1)

Fredrik Mörk
Fredrik Mörk

Reputation: 158289

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.

Upvotes: 3

Related Questions