关于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 ...
随机推荐
- LLVM example for main
#include "llvm/IR/CallSite.h" #include "llvm/IR/Instruction.h" #include "ll ...
- webpack配置sass模块的加载
webpack管理的项目,我们希望用sass定义样式,为了正常编译,需要做如下配置.这里不讲webpack的入门,入门的文章,我推荐这篇<webpack入门>. 为了使用sass,我们需要 ...
- 简单的通用TreeView(WPF)
工作中要为很多类创建TreeView, 很多时候仅仅是因为要显示字段不同, 就得Ctrl+C.Ctrl+V复制一份几乎相同的代码, 这难免让人生厌, 于是希望像泛型集合的扩展方法那样, 可以在使用的时 ...
- Fedora22编译Qt3.3.X
FC22编译QT3 安装g++ dnf install gcc-c++ 1,configure ./configure -thread -no-nis -system-libpng -system-l ...
- AngularJs自定义指令详解(10) - 执行次序
代码: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8 ...
- android app上线后bug的处理
app上线后,后期维护显得尤为重要,今天给大家分享一下app上线后出现bug后的解决方法 1.继承Application类,重写onCreate方法 import java.io.File; impo ...
- python 入门学习之环境搭载
1.常用python 2.7 需要在我的电脑环境变量进行环境搭载 2.用notepad++进行编辑器适配,选择python语言 在输入运行程序名里面输入cmd /k x: & cd " ...
- MySQL 性能优化的最佳20多条经验分享
当我们去设计数据库表结构,对操作数据库时(尤其是查表时的SQL语句),我们都需要注意数据操作的性能.这里,我们不会讲过多的SQL语句的优化,而只是针对MySQL这一Web应用最多的数据库.希望下面的这 ...
- [python] 创建临时文件-tempfile模块
This module generates temporary files and directories. It works on all supported platforms.In versio ...
- c# dotfuscator 混淆后无法使用
在实体类中忘记给字段加上 get ;set ;导致编译后程序无法使用. 下面这个(A代码)是可以正常混淆的. public class PhoneUsedStatus { ...