/// <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");
}

  

C#编辑EXE使用的appSettings节点的Config文件的更多相关文章

  1. 命令行工具aspnet_regiis.exe实现加密和解密web.config

    命令行工具aspnet_regiis.exe,是一个类似于DOS的命令工具,称之为命令解释器.使用命令行工具加密和解密web.config文件中的数据库连接字符串时,只需要简单的语法命令即可. 加密语 ...

  2. 利用HttpWebRequest模拟表单提交 JQuery 的一个轻量级 Guid 字符串拓展插件. 轻量级Config文件AppSettings节点编辑帮助类

    利用HttpWebRequest模拟表单提交   1 using System; 2 using System.Collections.Specialized; 3 using System.IO; ...

  3. 转载:轻量级Config文件AppSettings节点编辑帮助类

    using System.Configuration; using System.Windows.Forms; namespace Allyn.Common { public class XmlHep ...

  4. 轻量级Config文件AppSettings节点编辑帮助类

    using System.Configuration; using System.Windows.Forms; namespace Allyn.Common { public class XmlHep ...

  5. C# 对 App.config的appSettings节点数据进行加密

    .NET平台下的Winform和Asp.net的配置文件默认都是明文保存的,本文使用的是.Net自身如何加密配置文件,不包含自定义的加密规则 但.Net是提供了直接对配置文件加密的功能的,使用.Net ...

  6. c# 根据配置文件路径,设置和获取config文件 appSettings 节点值

    /// <summary> /// 获取编译后的主配置文件节点值 /// </summary> /// <param name="key">&l ...

  7. xml 方式更新和获取 配置文件 appSettings 节点 解决办法

    最近在搞一个小程序,会用到动态修改配置文件来进行处理,在百度上找了很多办法,但是始终达不到我预想的效果,先列出程序运行环境和开发工具版本: 开发工具:VS2010 .Net 运行环境:4.0 有两种方 ...

  8. 对获取config文件的appSettings节点简单封装

    转:http://www.cnblogs.com/marvin/archive/2011/07/29/EfficiencyAppSetting.html C#的开发中,无论你是winform开发还是w ...

  9. 关于C#和ASP.NET中对App.config和Web.config文件里的[appSettings]和[connectionStrings]节点进行新增、修改、删除和读取相关的操作

    最近我做的一些项目,经常需要用到对应用程序的配置文件操作,如app.config和web.config的配置文件,特别是对配置文件中的[appSettings]和[connectionStrings] ...

随机推荐

  1. 手把手在Ubuntu上面安装Docker

    一.环境准备 1.Ubuntu64位系统(目前docker仅支持64位系统) 2.官方支持的Ubuntu版本(1)Ubuntu Trusty 14.04(LTS)(2)Ubuntu Precise 1 ...

  2. paramiko之ssh登录,执行cmd,下载文件

    一.paramiko远程登录及执行命令 1.1:exec_command(cmd)远程执行命令 client = paramiko.SSHClient() client.set_missing_hos ...

  3. Go基础系列:为select设置超时时间

    Go channel系列: channel入门 为select设置超时时间 nil channel用法示例 双层channel用法示例 指定goroutine的执行顺序 After() 谁也无法保证某 ...

  4. shell编程基础(四): shell脚本语法之函数及调试

    一.Shell脚本中的函数 和C语言类似,Shell中也有函数的概念,但是函数定义中没有返回值也没有参数列表.例如: #! /bin/sh fun(){ echo "Function fun ...

  5. C#字符串。

    string类型不能被继承,它是密封类,sealed. 一.字符串的特性. 1.不可变性. class Program { static void Main(string[] args) { stri ...

  6. ___简单的MVC单个图片上传预览

    js: $("#btnImg").click(function () { $("#form0").ajaxSubmit({ url: "/Studen ...

  7. __EF批量删除

    控制器: [HttpPost] public int Delete_All(string Id) { List<int> IDS = new List<int>();//创建l ...

  8. ASP.NET登录验证

    protected void btnLogin_Click(object sender, EventArgs e) { string username = txtUserName.Value.Trim ...

  9. echarts X轴显示不全 有省略

    代码如下: xAxis: [ { type: 'category', data: result.weekListAndYear,//result.weekList, axisLabel:{ // in ...

  10. C# string数组转int数组

    用法 //字符串数组(源数组) string[] sNums = new[] {"1", "2"}; //整型数组(目标数组) int[] iNums; //转 ...