今天看到一招用DataSet修改WebConfig,真是簡潔明了,一同分享

public void write()
{
string newValue= this.TextBox1.Text;
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("")+"/web.config");
ds.Tables[1].Rows[0][1] = key1;
ds.AcceptChanges();
ds.WriteXml(Server.MapPath("")+"/web.config");
ds.Dispose();
}
本文轉自 王傑瑞 51CTO部落格,原文連結:http://blog.51cto.com/wangjierui/38536,如需轉載請自行聯系原作者