关于winform中*.exe.config中的appSettings的节点的读取与修改
//读取到这个节点
string file = System.Windows.Forms.Application.ExecutablePath;
Configuration config = ConfigurationManager.OpenExeConfiguration(file); string comNumber = config.AppSettings.Settings["comNumber"].Value.ToString();
comboBox1.SelectedItem = comNumber; //设置这个节点方法1,亲测可行
string file = System.Windows.Forms.Application.ExecutablePath;
Configuration config = ConfigurationManager.OpenExeConfiguration(file); bool exist = false;//记录这个com端口值是否存在
if (config.AppSettings.Settings["comNumber"] != null)
{
exist = true;
}
if (exist)
{
config.AppSettings.Settings.Remove("comNumber");
}
config.AppSettings.Settings.Add("comNumber", comNO);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
//方法2,因为上方法可行,这个并没有测试
//Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//config.AppSettings.Settings.
//config.AppSettings.Settings.Add("comNumber", comNO);
//config.Save(ConfigurationSaveMode.Full);
//ConfigurationManager.RefreshSection("appSettings");
导入的是一个System.Configuration的,
同样的connectionString也是差不多的,这里没有摘录,网上都是
关于winform中*.exe.config中的appSettings的节点的读取与修改的更多相关文章
- 用于获取或设置Web.config/*.exe.config中节点数据的辅助类
1. 用于获取或设置Web.config/*.exe.config中节点数据的辅助类 /**//// <summary> /// 用于获取或设置Web.config/*.exe.confi ...
- 从 exe.config 读取appSettings 中的配置数据
右键解决方案,添加引用--> System.Configuration.dll 在exe.config 中添加数据 <appSettings> <add key=" ...
- Debug目录、Release目录,bin目录、obj目录,vshost.exe.config文件、.exe.config文件分析【C#】
原文地址:http://blog.csdn.net/itwit/article/details/6803338 今天写程序的时候,需要更改.exe.config文件中的引用的webservice地址, ...
- 程序集、应用程序配置及App.config和YourSoft.exe.config .
转自:http://www.cnblogs.com/luminji/archive/2010/10/21/1857339.html 什么是程序集 程序集标识属性 强名称的程序集 强名称工作原理 配置文 ...
- 在Asp.Net MVC 中如何用JS访问Web.Config中appSettings的值
应用场景: 很多时候我们要在Web.Config中添加appSettings的键值对来标识一些全局的信息,比如:调用service的domain,跳转其他网站页面的url 等等: 那么此时就涉及到了一 ...
- [转]WinForm和WebForm下读取app.config web.config 中邮件配置的方法
本文转自:http://blog.csdn.net/jinbinhan/article/details/1598386 1. 在WinForm下读取 App.config中的邮件配置语句如下: Con ...
- ASP.NET MVC系列:web.config中ConnectionString aspnet_iis加密与AppSettings独立文件
1. web.config中ConnectionString aspnet_iis加密 web.config路径:E:\Projects\Libing.Web\web.config <conne ...
- winform中读取App.config中数据连接字符串
1.首先要在工程引用中导入System.Configuration.dll文件的引用. 2.通过System.Configuration.ConfigurationManager.Connection ...
- asp.net中web.config配置节点大全详解
最近网上找了一些关于Web.config配置节点的文章,发现很多都写的都比较零散,而且很少有说明各个配置节点的作用和用法.搜索了一下发现有一篇写的不错,这里引用一下 原文地址 http://www.c ...
随机推荐
- c++ cout介绍与实现自己的cout
C++编程语言互换流中的标准输出流,需要iostream支持.读为 "c out([si:‘aʊt]". 名字 cout 类型 std::ostream 读为 "c ou ...
- Brainstorm-the walkthrough example: Image Classification
(1) 运行create data,其中包括下载cifar10,并转换为hdf5格式(详见百度百科:http://baike.baidu.com/view/771949.htm#4_2): cifar ...
- HR常用事务代码
HR TCODE 描述 PA30 维护人力资源主数据 PA40 人事活动
- null 和 NULL 判断
遇到问题,服务器传回 null,我擦嘞,接收不了. 解决如下: NULL 直接 判断就好,能在 xcode 上直接敲出 null 的话 可以 ==[NSNull class] 或者[respons ...
- .net 控件
DevComponents.DotNetBar11.8.0.0:百度网盘里 DevExpress13.2.8:百度网盘里
- C# 小工具开发--DeBugHttp
随着RESTful的流行,前后端分离,我们后端开发人员在开发过程中多http相关方法进行测试.这就是这个小工具的初衷. 代码地址:https://github.com/gdoujkzz/DebugHt ...
- 类Collections的静态方法的使用(代码)
package cn.itcast.p2.toolclass.collections.demo; import java.util.ArrayList; import java.util.Collec ...
- MVC模式下向qq邮箱发送邮件
将已经保存在数据库中的密码通过邮件发送到qq邮箱中.用的ssm框架,其中的config文件要先配置好. 用到的jar包有gson-2.2.1.jar,gson.jar,mail.jar,activat ...
- 关于Scrum团队的理解
<阅读完<构建之法>第6~7章>之读后感 阅读完<构建之法>第6~7章之后,不仅感觉获益匪浅,也甚感团队合作.分配.工作的不易与一个团队运营一个项目并推广的艰辛与 ...
- Ubuntu搭建Ruby on Rails环境
安装Ruby 由于Ubuntu的apt包管理器的ruby版本过旧,故考虑从源码编译安装.这里以安装ruby2.3.0为例: sudo apt-get install build-essential z ...