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
查看全文
相关阅读:
异常-ERROR yarn.ApplicationMaster: User class threw exception: java.sql.SQLException: Communications link failure
异常-Data truncation: Truncated incorrect DOUBLE value: '-9370.3530-'
算法中的时间复杂度分析
MySQL开启binlog无法启动ct 10 21:27:31 postfix/pickup[4801]: warning: 6BD991A0039: message has been queue
【异常】ERROR main:com.cloudera.enterprise.dbutil.SqlFileRunner: Exception while executing ddl scripts. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ROLES' already exists
CDH5.16.1的agent启动报错:ERROR Error, CM server guid updated, expected d9bcadb4-f983-41b8-a667-66760f47bc91, received a67f5efa-8473-4f6a-94d6-231d1f432ef0
MySQL无法启动:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[Ubuntu] Ubuntu13.04, the desktop freezed after login
[ubuntu] ubuntu13.04安装rabbitcvs管理svn
[javascript] ajaxfileupload.js 跨域上传文件
原文地址:https://www.cnblogs.com/Dove/p/522533.html
最新文章
spring jdbc 源码
gradle 构建spring源码时候报错
sql trim()函数去掉两头空格
Hibernate的dynamic-insert和dynamic-update的使用
java vector 和ArrayList的区别
hashMap和hashTable的区别
java设计模式-代理模式
Apache ab测试工具使用方法(无参、get传参、post传参)
EXISTS/NOT EXISTS CASE WHEN等使用方法
学习如何看懂SQL Server执行计划——基本知识篇
热门文章
学习如何看懂SQL Server执行计划(三)——连接查询篇
web应用程序 前段部分调优
C# 中函数内定义函数的委托方法
支付接口 随机串 时间戳 防钓鱼效验方式
File FileStream StreamWriter StreamReader文件读写操作方法
普通<= >=和between的sql查询方式区别与推荐
学习如何看懂SQL Server执行计划(二)——函数计算篇
警告信息-Comparing unrelated types
【异常】airflow-psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
MacOS文本编辑无法打不开GB18030
Copyright © 2011-2022 走看看