2

I am very new to C# and I have read several posts about using configuration files. I have perhaps a very basic question I have been unable to find an answer to. I created a Config folder inside my project to put some path information for input/output files. There also seems to be a Config folder inside the \bin\debug\folder. My App.config file points to Config\appSettings.config. I can't figure out which Config folder is getting used in my project. Is it the Config folder I created or is it the Config folder inside the \bin\debug\ folder? Thanks in advance for any help and I hope I followed all the rules for posting a question.

Aliaksandr Sushkevich
  • 11,550
  • 7
  • 37
  • 44
lac55
  • 31
  • 3
  • It will use the file named `(YourExeFileName).config` in the same directory as the built executable (in this case `bin\Debug`). There is no concept of a "Config folder" in .NET. – Dai Apr 17 '18 at 16:03
  • Possible duplicate of [Reading dll.config (not app.config!) from a plugin module](https://stackoverflow.com/questions/1208793/reading-dll-config-not-app-config-from-a-plugin-module) – d219 Apr 17 '18 at 16:07
  • Thank you for your prompt response and this was very helpful. – lac55 Apr 19 '18 at 13:13

1 Answers1

0

I think that it's potentially both files.

Whenever you build your application, the compiled .exe, .dll and .config files are copied or written to the \bin\debug folder. The application is then run from the \bin\debug folder. The App.config file in your project directory gets automatically transformed into a file called ProjectName.exe.config which is what the ConfigurationManager class looks for.

If you use configSource in your App.config file to reference another configuration file such as Config\appSettings.config then this will also need to be copied to your \bin\debug folder so that it can be can be accessed when your program is run.

silleknarf
  • 1,219
  • 6
  • 22
  • Thank you for your prompt response. Your answer was very helpful and cleared up a lot of my confusion. – lac55 Apr 19 '18 at 13:13