C#Appconfig的读取与修改

黄沙百战穿金甲,不破楼兰终不还。这篇文章主要讲述C#Appconfig的读取与修改相关的知识,希望能为你提供帮助。
一、C#读取Appconfig内容
【C#Appconfig的读取与修改】private void button1_Click(object sender, EventArgs e)
{
string fileName=System.IO.Path.GetFileName(Application.ExecutablePath);
Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(fileName);
string value = https://www.songbingjia.com/android/config.AppSettings.Settings["ip"].Value = https://www.songbingjia.com/android/txtIP.Text;
string value1 = config.AppSettings.Settings["username"].Value = https://www.songbingjia.com/android/txtUserName.Text;
string value2 = config.AppSettings.Settings["userpwd"].Value = https://www.songbingjia.com/android/txtPassword.Text;
config.Save();
MessageBox.Show("保存成功!");

}
二、修改Appconfig
private void ServerSetting_Load(object sender, EventArgs e)
{
string fileName = System.IO.Path.GetFileName(Application.ExecutablePath);
Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(fileName);
string ip = config.AppSettings.Settings["ip"].Value;
string username = config.AppSettings.Settings["username"].Value ;
string userpwd = config.AppSettings.Settings["userpwd"].Value ;
txtIP.Text = ip;
txtUserName.Text = username;
txtPassword.Text = userpwd;
}





















    推荐阅读