C#设置加载并保存 [英] C# Setting load and save
本文介绍了C#设置加载并保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用此代码加载和保存设置,但是当我关闭并重新运行程序时,未加载设置.默认情况下,设置为空白.我没有错误.
I trying to load and save setting with this code but when I closing and rerun program the settings not loaded. By default the settings was blank. I have no error.
private void Form1_Load(object sender, EventArgs e)
{
txtUsername.Text = Properties.Settings.Default.Username;
txtPassword.Text = Properties.Settings.Default.Password;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.Username = txtUsername.Text;
Properties.Settings.Default.Password = txtPassword.Text;
}
推荐答案
尝试
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.Username = txtUsername.Text;
Properties.Settings.Default.Password = txtPassword.Text;
Properties.Settings.Default.Save();
}
这篇关于C#设置加载并保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文