读写web.config
using System.Data;
读web.config:
string str_webconfig = Server.MapPath("Web.config");
DataSet dsxml = new DataSet();
dsxml.ReadXml(str_webconfig);
newsname.Text = dsxml.Tables[1].Rows[0][1].ToString();
newsurl.Text = dsxml.Tables[1].Rows[1][1].ToString();
copyright.Text = dsxml.Tables[1].Rows[2][1].ToString();
.................................

写web.config:
string str_webconfig = HttpContext.Current.Server.MapPath("Web.config");
   DataSet dsxml = new DataSet();
   try
   {
    dsxml.ReadXml(str_webconfig);
    dsxml.Tables[1].Rows[0][1] = newsname.Text;
    dsxml.Tables[1].Rows[1][1] = newsurl.Text;
    dsxml.Tables[1].Rows[2][1] = copyright.Text;
    dsxml.Tables[1].Rows[3][1] = badword.Text;
........................................
    dsxml.AcceptChanges();
    dsxml.WriteXml(str_webconfig);
    dsxml.Clear();
}
catch (Exception exc)
   {
       throw new Exception(exc.Message);

相关文章:

  • 2021-12-09
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
猜你喜欢
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-01-24
  • 2021-04-10
  • 2022-02-07
  • 2022-02-16
相关资源
相似解决方案