using
System;
using System.Configuration;
using System.Reflection;
using System.Web;
using System.Xml;
/* 编写日期: 2008.4.4
* 更新日期:
* 编写人 :James.Chen
* 修改历史及原因:
*
*/
namespace AppFrameWork
{
/// <summary>
/// 配置文件类型,是WinForm还是WebForm
/// </summary>
public enum ConfigFileType
{
WebConfig,
AppConfig
}
/// <summary>
/// 对AppSettings节点进行增加,删除,修改操作.
/// </summary>
public class AppSettingsHelper
{
public static string docName = String.Empty;
private static XmlNode node = null ;
/// <summary>
/// 设置节点的值,若该节点不存在,则创建一个新的节点。
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="cfgType"></param>
/// <returns></returns>
public static bool SetValue( string key, string value, ConfigFileType cfgType)
{
XmlDocument cfgDoc = new XmlDocument();
loadConfigDoc(cfgDoc, cfgType);
// retrieve the appSettings node
node = cfgDoc.SelectSingleNode( " //appSettings " );
if (node == null )
{
throw new InvalidOperationException( " appSettings section not found "
using System.Configuration;
using System.Reflection;
using System.Web;
using System.Xml;
/* 编写日期: 2008.4.4
* 更新日期:
* 编写人 :James.Chen
* 修改历史及原因:
*
*/
namespace AppFrameWork
{
/// <summary>
/// 配置文件类型,是WinForm还是WebForm
/// </summary>
public enum ConfigFileType
{
WebConfig,
AppConfig
}
/// <summary>
/// 对AppSettings节点进行增加,删除,修改操作.
/// </summary>
public class AppSettingsHelper
{
public static string docName = String.Empty;
private static XmlNode node = null ;
/// <summary>
/// 设置节点的值,若该节点不存在,则创建一个新的节点。
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="cfgType"></param>
/// <returns></returns>
public static bool SetValue( string key, string value, ConfigFileType cfgType)
{
XmlDocument cfgDoc = new XmlDocument();
loadConfigDoc(cfgDoc, cfgType);
// retrieve the appSettings node
node = cfgDoc.SelectSingleNode( " //appSettings " );
if (node == null )
{
throw new InvalidOperationException( " appSettings section not found "