zoukankan
html css js c++ java
.NET 2.0中,配置文件app.config的读写(VS2005,C#) PENGHAO
在.NET 2.0中对配置文件app.config文件的读写变得相当简单了,在创建一个新的项目后VS2005会自动生成配置文件(Settings.settings)及app.config,如没有请:右键项目--属性--设置里添加一条配置信息(如下图),VS2005将自动生成这些文件:
Settings.Designer.cs
namespace
WindowsApplication1.Properties
{
internal
sealed
partial
class
Settings :
global::System.Configuration.ApplicationSettingsBase
{
private
static
Settings defaultInstance
=
((Settings)
(global::System.Configuration.ApplicationSettingsBase.Synchronized(
new
Settings())));
public
static
Settings Default
{
get
{
return
defaultInstance; }
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(
"
Form1
"
)]
public
string
testSetting
{
get
{
return
((
string
)(
this
[
"
testSetting
"
])); }
set
{
this
[
"
testSetting
"
]
=
value; }
}
}
}
VS2005基本都完成了,现在我们读写时就只需要写几行代码就行了:
Properties.Settings config
=
Properties.Settings.Default;
//
读取
string
str
=
config.testSetting;
//
写入
config.testSetting
=
"
test value
"
;
config.Save();
其它更详细的写方法介绍:
http://www.codeproject.com/useritems/SystemConfiguration.asp
http://www.codeproject.com/useritems/SystemConfiguration.asp
查看全文
相关阅读:
Winget
全部所学知识
重装系统
srs更改端口号导致webrtc播放异常
.NET性能优化方面的总结(转)
从自动变换页面背景CSS改写成变换背景图
网页级在线性能网站测试介绍
ASP.NET服务器端控件学习(一)
Nginx源码分析内存池
使用Memcached提高.NET应用程序的性能
原文地址:https://www.cnblogs.com/Dove/p/522533.html
最新文章
Kubernetes集群PV和PVC详解
重启WAS实例
二进制方式搭建Kubernetes高可用集群
OLTP与OLAP的区别
网络分层和TCP三次握手
jenkins pipeline设置
Vue 从小白到大神
好用的Vue自定义指令
ubuntu下最好用的输入法fcitxsunpinyin
关于memset
热门文章
C++ Boost Thread 编程指南
最大连续子数列和问题
A*寻路初探
判断点是否在三角形内
在A*寻路中使用二叉堆
A*分层寻路
安装部署mongodb
JavaWeb
C# GUI(Winform)
Docker
Copyright © 2011-2022 走看看