//查询AppSettings的key
public static List sql()
{
List list = new List();
int Lh = ConfigurationManager.AppSettings.AllKeys.Length;
for (int i = 0; i < Lh; i++)
{
list.Add(ConfigurationManager.AppSettings.AllKeys.GetValue(i).ToString());
}
return list;
}
//查询值AppSettings的值
public static string SValue(string key)
{
return ConfigurationManager.AppSettings[key].ToString();
}
//添加AppSettings,key ,值
public static int insert(string key, string Sver)
{
int i = 0;
try
{
Configuration conn = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection app = conn.AppSettings;
app.Settings.Add(key, Sver);
conn.Save(ConfigurationSaveMode.Minimal);
return i;
}
catch
{
return i = 1;
}
}
//修改AppSettings,key ,值
public static int update(string key, string Sver)
{
int e = 0;
try
{
Configuration conn = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection app = conn.AppSettings;
app.Settings[key].Value = Sver;
conn.Save(ConfigurationSaveMode.Minimal);
return e;
}
catch
{
return e = 1;
}
}
//删除AppSettings,key ,值
public static int delete(string key)
{
int s = 0;
try
{
Configuration conn = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection app = conn.AppSettings;
app.Settings.Remove(key);
conn.Save(ConfigurationSaveMode.Minimal);
return s;
}
catch
{
return s = 1;
}
}