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

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);

你可能感兴趣的:(application)