0

I have an app.config file in my project and I am able to read from it using

public static String baseURL = ConfigurationManager.AppSettings["baseURL"];

My problem is I have lots of entries in my app.config file and I want to have multiple config files to split the data logically.

So I basically want to have several config files as follows:

Strings.config     (to hold all Strings)
Urls.config        (to hold all URLs)
Settings.config    (to hold all settings)
Credentials.config (to hold all credentials)

How can I read values from different config files?

Honza Zidek
  • 9,204
  • 4
  • 72
  • 118
Ajay S
  • 369
  • 3
  • 5
  • 12
  • You should build your own wrapper around your config files, the configurationmanager-namespace provides interaction with your web.config/app.config file only. Edit: Or you devide your config file into different sections. Then you can still use this namespace, but you will need to implement a few other things. – Trickzter Mar 30 '16 at 12:19
  • You might add Strings.config, Urls.config locations e.t.c. to web.config/app.config and then read them as a files... downside - you`ll have to parse them by your own wrapper not System.Configuration. Also http://stackoverflow.com/questions/1838619/relocating-app-config-file-to-a-custom-path might help you – Vladimir Mar 30 '16 at 12:26
  • Are you opposed to writing your own configuration section handlers? – Mike Cheel Mar 30 '16 at 13:15

0 Answers0