请注意引用using System.Configuration;
using System;
using System.Data;
using System.Net;
using System.Windows.Forms;
using System.Configuration;
namespace TY.Kanban.Prod
{
public partial class Kanban_Prod_A : Form
{
public Kanban_Prod_A()
{
}
private void Kanban_Prod_A_Load(object sender, EventArgs e)
{
}
private void GetConnectionStrings()
{
string str = System.Configuration.ConfigurationManager.AppSettings.GetValues("pw")[0];
this.Text = str;
}
static void DisplayAppSettings()
{
try
{
AppSettingsReader reader = new AppSettingsReader();
NameValueCollection appSettings = ConfigurationManager.AppSettings;
for (int i = 0; i < appSettings.Count; i++)
{
Console.WriteLine("Key : {0} Value: {1}",
appSettings.GetKey(i), appSettings[i]);
}
}
catch (ConfigurationErrorsException e)
{
Console.WriteLine("[DisplayAppSettings: {0}]", e.ToString());
}
}
}
}