Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load the App.config file?

I'm parsing the App.config file of a project. This config file has been loaded from a caller project. Inside the called project, I have something like:

   XmlDocument xmlDoc = new XmlDocument();
   xmlDoc.Load("app.config");
   // Some parsing...

Unfortunately the app.config file is not correctly located. Apparently the Load method is browsing the ~/bin/Release directory of the caller project, but the app.config file is located in the ~ directory.

Is there any way I can load this App.config file correctly?

Thanks

like image 493
Amokrane Chentir Avatar asked Nov 30 '22 10:11

Amokrane Chentir


1 Answers

I don't understand why you need to do this. The configuration file App.Config is copied to the runtime directory at build time and renamed yourapplicationname.exe.config.

You can use the ConfigurationManager class to access the contents of that file.

like image 138
Klaus Byskov Pedersen Avatar answered Dec 15 '22 02:12

Klaus Byskov Pedersen