How to move app.config to another folder inside Solution Explorer?

I use Visual Studio 2010. In my Solution Explorer, I like to sort project elements into folders (folder for forms, folder for classes, folder Misc, etc.).

It seems that if I moved the "app.config" file to a folder named "Config Files", everything will work until I change the setting in the Settings.settings file. As soon as I do this, a new app.config is created, and the one that was in the "Config Files" folder is not updated.

I searched the whole solution for the text "app.config" and did not find any results. How do I transfer this file so that my solution explorer looks beautiful and clean?

+7
visual-studio-2010 winforms
source share
2 answers

No, app.config should be in the main folder of the project, but you can "screen" any configuration section inside app.config using the configSource= attribute:

 <connectionStrings configSource="config\db\connectionstrings.config" /> <system.net> <mailSettings> <smtp configSource="config\mail\smtp.dev.config" /> </mailSettings> </system.net> <system.serviceModel> <behaviors configSource="config\wcf\behaviors.config" /> <binding configSource="config\wcf\bindings.config" /> <client configSource="config\wcf\client.config" /> </system.serviceModel> 
+7
source share

AFAIK, you cannot change the location of the default configuration file. Although, if you need a different configuration file, you can use the ExeConfigurationFileMap class.

+1
source share

All Articles