我正在尝试创建更新配置文件的应用程序。单击事件来更新文件C#
我已经做了以下形式:
我也创建了下面的代码:
using System;
using System.IO;
using System.Windows.Forms;
namespace DebugOnOrOff
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string text = File.ReadAllText("C:\\Users\\User\\Desktop\\app.config");
text = text.Replace("DebugOff", "DebugOn");
File.WriteAllText("app.config", text);
}
}
}
问题是? – kennyzx
你做错了,有指定的方式来更新应用程序设置。查看[this]的第一个答案(https://stackoverflow.com/questions/453161/best-practice-to-save-application-settings-in-a-windows-forms-application)question –
可能重复[Best练习在Windows窗体应用程序中保存应用程序设置](https://stackoverflow.com/questions/453161/best-practice-to-save-application-settings-in-a-windows-forms-application) – Igor