Skip to: Site menu | Main content

Login

Name: 
Password:
Remember me?
Register

App.Config

written by Mark Rowlinson - Last updated Jun 2006

  1. Select add new item
  2. Select Application Configuration File

You should now have an app.config file within your project. The text of this file will look like this:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>

The next step is to add an <appSettings></appSettings> section inside the configuration section. Within this you can then add configuration items in key value pairs. For example if you wanted a configuration option 'Interval' that specified the time in seconds an application should wait before doing something you could add the following:


<add key="Interval" value="10" />

You can then access this configuration option in the code of your application using the following code:

 
Interval = CInt(System.Configuration.ConfigurationSettings.AppSettings.Get(\"Interval\")) 
 

The complete config file would look like this:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Interval" value="10" />
</appSettings>
</configuration>