APP.config/web.config编辑类
2005-08-05 11:04
239 查看
using System;
using System.Configuration;
using System.Reflection;
using System.Web;
using System.Xml;
public enum ConfigFileType
namespace fenghua.Configuration
使用方法:
1.app.config
2.修改web.config:
using System.Configuration;
using System.Reflection;
using System.Web;
using System.Xml;
public enum ConfigFileType
namespace fenghua.Configuration
使用方法:
1.app.config
private void Form1_Load(object sender, System.EventArgs e) { AppConfig config = new AppConfig(); config.ConfigType= (int)ConfigFileType.AppConfig; bool bln= (bool)( config.GetValue( "Boolean", typeof( bool ) ) ); string str= (string)( config.GetValue( "String", typeof( string ) ) ); DateTime date = (DateTime)( config.GetValue( "DateTime", typeof( DateTime ) ) ); bln = !bln; str = str + "-" + "there"; date = date.AddDays( 1 ); config.SetValue( "Boolean", bln.ToString() ); config.SetValue( "String", str ); config.SetValue( "DateTime", date.ToShortDateString() ); config.SetValue("testing", "1234506"); config.SetValue("howdy", "there"); string str2= (string)( config.GetValue( "howdy", typeof( string ) ) ); textBox1.Text+= bln +" "; textBox1.Text+= str2+" " ; textBox1.Text+= date.ToShortDateString()+" " ; // uncomment to see element removed //config.removeElement("howdy"); }
2.修改web.config:
private void Page_Load(object sender, System.EventArgs e) { AppConfig config = new AppConfig(); //config.ConfigType = (int)ConfigFileType.WebConfig; bool bln= (bool)( config.GetValue( "Boolean", typeof( bool ) ) ); string str= (string)( config.GetValue( "String", typeof( string ) ) ); DateTime date = (DateTime)( config.GetValue( "DateTime", typeof( DateTime ) ) ); bln = !bln; str = str + "-" + "there"; date = date.AddDays( 1 ); config.SetValue( "Boolean", bln.ToString() ); config.SetValue( "String", str ); config.SetValue( "DateTime", date.ToShortDateString() ); config.SetValue("testing", "1234506"); config.SetValue("howdy", "there"); string str2= (string)( config.GetValue( "howdy", typeof( string ) ) ); Response.Write( bln + "<BR>" ); Response.Write( str2 + "<BR>"); Response.Write( date.ToShortDateString() + "<BR>" ); // uncomment to see element removed //config.removeElement("howdy"); }
相关文章推荐
- 读取webconfig里面的appSetting和connectionString
- 遇见 App.Config 、SAE 、 WEB
- 操作App.config与Web.config文件
- Web.config/App.config 加密解密
- C#/ASP.NET应用程序配置文件app.config/web.config的增、删、改操作
- app.config或web.config存放数据库连接字符串的两种方式
- global.asax?app.config?webconfig??
- Visual Studio实现xml文件使用app.config、web.config等的智能提示
- 在Web.config或App.config中的添加自定义配置
- asp.net 配置文件(Machine.config、Web.config、App.config)
- ASP.NET web.config 中<appSettings>的设定Oracle连线tns
- AppSettings In web.config
- The difference between Web.config and App.config.
- 加密App.Config文件和Web.Config
- web.config/app.config敏感数据加/解密的二种方法
- arcgis webAppBuilder----config.json解析
- netcore web.config ConnectionStrings AppSettings
- 关于C#和ASP.NET中对App.config和Web.config文件里的[appSettings]和[connectionStrings]节点进行新增、修改、删除和读取相关的操作
- 创建自定义配置节点(web.config和app.config都适用)【转载】
- 操作App.config与Web.config文件 [ZT]