修改Web.Config里的值

public void Modify(string key, string value)

{

Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");

AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");

   if (appSettingsSection != null)

   {

       appSettingsSection.Settings[key].Value = value;

       config.Save();

   }

}

你可能感兴趣的:(config)