zoukankan
html css js c++ java
在程序里修改配置文件
不废话了直接就写代码吧,在Web应用程序中可以用下面的方法
System.Configuration.Configuration config
=
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(
null
);
if
(
null
==
config.AppSettings.Settings[
"
test
"
])
{
config.AppSettings.Settings.Add(
"
test
"
,
this
.TextBox1.Text);
}
else
{
config.AppSettings.Settings.Remove(
"
test
"
);
config.AppSettings.Settings.Add(
"
test
"
,
this
.TextBox1.Text);
}
config.Save();
在Windows应用程序中可以使用下面的方法
System.Configuration.Configuration config
=
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if
(config.AppSettings.Settings[
"
setServer
"
]
==
null
)
{
config.AppSettings.Settings.Add(
"
setServer
"
,
this
.textBox1.Text);
config.Save(ConfigurationSaveMode.Full);
}
else
{
config.AppSettings.Settings.Remove(
"
setServer
"
);
config.AppSettings.Settings.Add(
"
setServer
"
,
this
.textBox1.Text);
config.Save(ConfigurationSaveMode.Full);
}
到这里我需要说一些注意事项
1.在Windows应用程序中默认情况下没有添加对System.configuration的引用,所以即使using System.Configuration;也
无法使用ConfigurationManager,所以我们需要添加System.configuration的引用。
查看全文
相关阅读:
rabbitmq 安装和配置
rabbitmq
Redis Keys 命令
python pickle模块
Redis之Python操作
flask中的g、add_url_rule、send_from_directory、static_url_path、static_folder的用法
Python 并行分布式框架 Celery
Celery+python+redis异步执行定时任务
feed流拉取,读扩散,究竟是啥?
DNS解析
原文地址:https://www.cnblogs.com/interboy/p/722894.html
最新文章
08-08 细分构建机器学习应用程序的流程-模型优化
02-12 Logistic(逻辑)回归
A-04 坐标轴下降法
web development blog(转)
手机web——自适应网页设计(html/css控制)(转)
移动对meta的定义(转)
Google map API V3
[Python]项目打包:5步将py文件打包成exe文件(转)
[Python]网络爬虫(九):百度贴吧的网络爬虫(v0.4)源码及解析(转)
[Python]网络爬虫(八):糗事百科的网络爬虫(v0.2)源码及解析(转)
热门文章
[Python]网络爬虫(七):Python中的正则表达式教程(转)
[Python]网络爬虫(六):一个简单的百度贴吧的小爬虫(转)
[Python]网络爬虫(五):urllib2的使用细节与抓站技巧(转)
2016新年快乐
atmega32u4制作arduino leonardo最小系统
利用EEPROM实现arduino的断电存储
3分钟学会做智能插座(DIY)
利用 ProtoThreads实现Arduino多线程处理(2)
python 生成器和迭代器
斐波那契数列
Copyright © 2011-2022 走看看