C#编辑EXE使用的appSettings节点的Config文件
程序员文章站
2022-03-23 19:13:55
/// /// 保存配置文件的设定 /// /// /// public static void SaveAppConfig(string Key,string Value) { string strFilePath = System.Windows.Forms... ......
/// <summary>
/// 保存配置文件的设定
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public static void saveappconfig(string key,string value)
{
string strfilepath = system.windows.forms.application.executablepath;
configuration objconfig = configurationmanager.openexeconfiguration(strfilepath);
bool bolexist = false;
foreach (string item in objconfig.appsettings.settings.allkeys)
{
if (item == key)
{
bolexist = true;
break;
}
}
if (bolexist)
{
objconfig.appsettings.settings.remove(key);
}
objconfig.appsettings.settings.add(key,value);
objconfig.save(configurationsavemode.modified);
configurationmanager.refreshsection("appsettings");
}
上一篇: javascript怎么求5的阶乘
下一篇: ASP编写完整的一个IP所在地搜索类