VS2005里读取及改变Appconfig里appSettings节的值

上传人:d**** 文档编号:174118369 上传时间:2022-12-14 格式:DOCX 页数:3 大小:8.62KB
返回 下载 相关 举报
VS2005里读取及改变Appconfig里appSettings节的值_第1页
第1页 / 共3页
VS2005里读取及改变Appconfig里appSettings节的值_第2页
第2页 / 共3页
VS2005里读取及改变Appconfig里appSettings节的值_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述
VS2005(C#)里读取及改变Appconfig里appSettings节的值.txt21春暖花会开!如果你曾经 历过冬天,那么你就会有春色!如果你有着信念,那么春天一定会遥远;如果你正在付出, 那么总有一天你会拥有花开满圆。VS2005 (C#)里读取及改变App.config里appSettings 节的值 标签: App.config 2011-01-30 10:48using System;using System.Collections.Generic;using System.Text;using System.Configuration;using System.Collections;namespace ServicesConfigurationpublic class ConfigurationDisposepublic ConfigurationDispose()#region GetConfiguration/ / 取得 appSettings 里的值/ / param name二key键/param/ returns值/returnspublic static string GetConfiguration(string key)return ConfigurationManager.AppSettingskey;#endregion#region GetConfigurationList/ summary/ 取得 appSettings 里的值列表/ /summary/param name二filePa th配置文件路径/param/ re tu rns值列表/re tu rnspublic static KeyValueConfigurationCollectionGetConfigurationList(string filePath)AppSettingsSectionappSection=null;/AppSec tion 对象Configurationconfiguration=null;/Configura tion 对象KeyValueConfigurationCollection k = null;/返回的键值对类型configuration = ConfigurationManager.OpenExeConfiguration(filePath);/取得 AppSettings 节 appSection = (AppSettingsSection)configuration.SectionsappSettings;/取得 AppSetting 节的键值对k = appSection.Settings;return k;#endregion#region SetConfiguration/ / 设置 appSetting 的值/ / param name二key键/param/ param name二value值/param/param name二filePa thApp.config 文件路径/parampublic static void SetConfiguration(string key, string value,string filePath)Configuration configuration = null;/Configuration对象AppSe tti ngsSec tion appSec tion 二 null;/AppSec tior对象configuration = ConfigurationManager.OpenExeConfiguration(filePath);/取得 AppSetting 节appSection = configuration.AppSettings;/赋值并保存appSection.Settingskey.Value = value; configuration.Save();#endregion #region SetConfiguration/ / 设置 appSetting 的值/ / param name二key键/param/ param name二value值/parampublic static void SetConfiguration(string key, string value) AppSe tti ngsSec tion appSec tion 二 null;/AppSec tior对象appSection = ConfigurationManager.GetSection(appSettings);appSection.Settingskey.Value = value;#endregion
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!