How to change location of app.config

后端 未结 4 630
甜味超标
甜味超标 2020-12-15 11:51

I want to change the location where my application looks for the app.config file.

I know that I can use ConfigurationManager.OpenExeConfiguration() to access an ar

4条回答
  •  甜味超标
    2020-12-15 12:14

    I am not sure why you want to change the location of your config file - perhaps there can be different approach for solving your actual problem. I had a requirement where I wanted to share configuration file across related applications - I had chosen to use own xml file as it had given me extra benefit of having complete control over the schema.

    In your case, it's possible to externalize sections of your config file to a separate file using configSource property. See here under "Using External Configuration Files" to check how it has been done for connection strings section. Perhaps, this may help you.

提交回复
热议问题