读写web.config
读写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);
读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);