I want to read the <appSettings>
section of the App.config
file using my own xml code (not linq to xml):
Here's my app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="driver" value="C:/"/>
<add key="daysToExpire" value="0"/>
<add key="Interval" value="5000"/>
</appSettings>
<system.net>
<mailSettings >
<smtp>
<network enableSsl="false"
port="25"
host="smtp.gmail.com"
defaultCredentials="false"
/>
</smtp>
</mailSettings>
</system.net>
My c# code:
XmlDocument doc = new XmlDocument();
doc.Load(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.xml")
);
XmlNodeList appSettings = doc.SelectNodes("/configuration/appSettings/add");
Driver = appSettings[0].Attributes[0].Value;
Interval = Convert.ToInt16(appSettings[2].Value);
DaysToExpire = Convert.ToInt16(appSettings[1].Value);
appSettings
has 3 modes but I didn't manage to access each one.
I also want to read the system.net
section.