Application_Start事件中修改配置文件内容 dodo

string configFile =  System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath + "dnt.config");
   XmlDocument xDoc = new XmlDocument();
   xDoc.Load(configFile);
   XmlNodeList xnl = xDoc.GetElementsByTagName("Dbconnectstring");
   //xnl[0].InnerText = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath("bbs/database/access_db.config") + ";Persist Security Info=True;";
   xnl[0].InnerText = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath + "bbs/database/access_db.config") + ";Persist Security Info=True;";
   xDoc.Save(configFile);
原文地址:https://www.cnblogs.com/zgqys1980/p/607212.html