I am trying to create a Windows Server. I have some logic in C#
string urlToPing = ConfigurationSettings.AppSettings["UrlToPing"].ToString(); Stream data = client.OpenRead(urlToPing);
I need to read
Here my App.Config
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="UrlToPing" value="http://mysite.com"/> </appSettings> </configuration>
I am new at Windows Services, my questions:
The <appSettings> element stores custom application configuration information, such as database connection strings, file paths, XML Web service URLs, or any other custom configuration information for an application.
To my second question I found a solution:
Add a reference to System.Configuration to your code file.
using System.Configuration;
The setting may now be referenced correctly...
ConfigurationManager.AppSettings["UrlToPing"].ToString();
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