Quantcast
Channel: Reading settings from app.config or web.config in .NET - Stack Overflow
Viewing all articles
Browse latest Browse all 29

Answer by Ram for Reading settings from app.config or web.config in .NET

$
0
0

For a sample app.config file like below:

<?xml version="1.0" encoding="utf-8" ?><configuration><appSettings><add key="countoffiles" value="7" /><add key="logfilelocation" value="abc.txt" /></appSettings></configuration>

You read the above application settings using the code shown below:

using System.Configuration;

You may also need to also add a reference to System.Configuration in your project if there isn't one already. You can then access the values like so:

string configvalue1 = ConfigurationManager.AppSettings["countoffiles"];string configvalue2 = ConfigurationManager.AppSettings["logfilelocation"];

Viewing all articles
Browse latest Browse all 29

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>