Read values from configuration file
To get the following code to work add a configuration file to your application /console application using Visual Basic => Add => New Item … => Application Configuration File. By following this a file called App.config should appear in your root directory of you project.
/* App.config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myValueKey" value="c:\test.txt" />
</appSettings>
</configuration>
*/
using System;
using System.Configuration;
...
AppSettingsReader config = new AppSettingsReader();
// get defaults via key => myValueKey
string observerDirectory = (string)config.GetValue("myValueKey", typeof(string));
Comments
Du mußt Dich einloggen um diesen Weblog kommentieren zu können!
There were no comments found for this weblog.