今天看到一招用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,如需转载请自行联系原作者