如何读写 app.config

如何读写 app.config

using System;
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
using System.Collections.Generic;
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
using System.Text;
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
using System.Configuration;
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
using System.Collections;
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
namespace ServicesConfiguration
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
{
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追    
public class ConfigurationDispose
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追    
{
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
public ConfigurationDispose()
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
{
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追         }

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
#region GetConfiguration
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// <summary>
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// 取得appSettings里的值
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// </summary>
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// <param name="key"></param>
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// <returns></returns>

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        public static string GetConfiguration(string key)
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
{
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追            
return ConfigurationManager.AppSettings[key];
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追         }

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
#endregion

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
#region GetConfigurationList
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// <summary>
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// 取得appSettings里的值列表
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// </summary>
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// <param name="filePath">配置文件路径</param>
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
/// <returns>值列表</returns>

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        public static KeyValueConfigurationCollection GetConfigurationList(string filePath)
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
{
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追             AppSettingsSection appSection
= null;                       //AppSection对象
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
             Configuration configuration = null;                         //Configuration对象     
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
             KeyValueConfigurationCollection k = null;                   //返回的键值对类型
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追             configuration
= ConfigurationManager.OpenExeConfiguration(filePath);
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追            
//取得AppSettings节
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
             appSection = (AppSettingsSection)configuration.Sections["appSettings"];
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追            
//取得AppSetting节的键值对
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
             k = appSection.Settings;
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追            
return k;
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追                    
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追         }

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追        
#endregion

VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追
VS2005 如何读写 app.config -  上年纪的程序员  - 有梦就追     

原文地址:https://www.cnblogs.com/zzxap/p/2175880.html