Home

How do I connect the App.config?

Question.
1. How do I connect the App.config?
2. Did I connect the App.config correctly?

I am trying to connect App.config.
When I try to extract data from App.config I connect null.

Description.
Settings

Debugging

void ReadConfig()
{
 var con = ConfigurationManager.ConnectionStrings["App"];

 var path = ConfigurationManager.GetSection("countoffiles");

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

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

I use:
- LINQPAD 6.9.15x64.

Comments

Sign In or Register to comment.