This works for me:
string value = System.Configuration.ConfigurationManager.AppSettings[key];
The answer that dtsg gave works:
string filePath = ConfigurationManager.AppSettings["ClientsFilePath"];
BUT, you need to add an assembly reference to
System.Configuration
Go to your Solution Explorer and right click on References and select Add reference. Select the Assemblies tab and search for Configuration.
Here is an example of my App.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="AdminName" value="My Name"/>
<add key="AdminEMail" value="MyEMailAddress"/>
</appSettings>
</configuration>
Which you can get in the following way:
string adminName = ConfigurationManager.AppSettings["AdminName"];
Give this a go:
string filePath = ConfigurationManager.AppSettings["ClientsFilePath"];
Read From Config :
You'll need to add a reference to Config
string value = Properties.Settings.Default.keyname;
Save to Config :
Properties.Settings.Default.keyName = value;
Properties.Settings.Default.Save();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With