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);
posted @ 2006-12-29 17:04  dodo-yufan  阅读(647)  评论(0编辑  收藏  举报