Hi I'm trying to implement a simple c# config file within my program. However I cannot figure out why I have an error with "ConfigurationSettings.AppSettings." I thought that this was referenced with "System.Configuration." I was looking for another reference like "System.configuration.ConfigurationSettings" but there isn't one. I'm not sure what I'm doing wrong. I found some simple code off of the internet but I cannot get it to work. Am I placing the code in the wrong part of the form?
I will list it below. Any help is appreciated! Thanks.
App.config:
Code:
<?xml version="1.0" encoding= "utf-8" ?>
<configuration>
<appSettings>
<add key="DatabasePath" value="c:\\projects\data\spider.mdb" />
<add key="SupportEmail" value="[email protected]" />
</appSettings>
</configuration>
Form:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
namespace ConfigTest2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string dbPath = ConfigurationSettings.AppSettings["DatabasePath"];
string email = ConfigurationSettings.AppSettings["SupportEmail"];
}
}
}