准备:
     在 项目/<项目名>属性/设置 选项卡里可以定义变量,范围中用户(User)指该变量可读写,程序(application)指只读,例如定义以下变量:
 保存程序配置到config文件里
读取方法:

        private void Form1_Activated(object sender, EventArgs e)
        {
            textBox1.Text = Properties.Settings.Default.Text;
            textBox1.BackColor=Properties.Settings.Default.Backcolor;
        }

保存方法:
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Properties.Settings.Default.Text = textBox1.Text;
            Properties.Settings.Default.Backcolor = textBox1.BackColor;
            Properties.Settings.Default.Save();
        } 

注意: 在文件夹C:/Documents and Settings/Windows登录用户/Local Settings/Application Data/ 下 搜索:user.config  可找到该配置文件

相关文章:

  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2021-12-28
  • 2021-06-13
猜你喜欢
  • 2021-07-16
  • 2021-07-26
  • 2021-11-04
  • 2022-02-04
  • 2021-04-14
  • 2021-05-20
相关资源
相似解决方案