using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
//操作appSettings
AppSettingsSection appseting = (AppSettingsSection)config.GetSection("appSettings");
appseting.Settings["web"].Value = "张三"; //修改设置
appseting.Settings.Add("name", "张三"); //增加设置
//操作connectionStrings
ConnectionStringsSection conSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
conSection.ConnectionStrings["constr"].ConnectionString = "htttp://study.pctoday.net.cn/App_Data/zhangshan.mdb"; //修改设置
conSection.ConnectionStrings["constr"].ProviderName = "System.Data.OleDb";
conSection.ConnectionStrings.Add(new ConnectionStringSettings("constr2", "bbbb", "System.Data.OleDb")); //增加设置
config.Save();
}
}