C# 中Web.config文件的读取与写入
asp.net2.0新添加了对web.config直接操作的功能。开发的时候有可能用到在web.config里设置配置文件,其实是可以通过程序来设置这些配置节的。
asp.net2.0需要添加引用:
using System.Web.Configuration;
web.config里的配置节:
<appSettings>
<add key="FilePath" value="g:\Test\WebConfigManager\Upload\" />
<add key="p" value="g:\" />
</appSettings>
(1)读
string filepath = ConfigurationManager.AppSettings["FilePath"];
Configuration config = WebConfigurationManager.OpenWebConfiguration("/WebConfigManager");
AppSettingsSection app = config.AppSettings;
app.Settings.Add("p", "p:\\");
config.Save(ConfigurationSaveMode.Modified);
Configuration config = WebConfigurationManager.OpenWebConfiguration("/WebConfigManager");
AppSettingsSection app = config.AppSettings;
app.Settings["p"].Value = @"g:\";
config.Save(ConfigurationSaveMode.Modified);
Configuration config = WebConfigurationManager.OpenWebConfiguration("/WebConfigManager");
AppSettingsSection app = config.AppSettings;
app.Settings.Remove("p");
config.Save(ConfigurationSaveMode.Modified);
C# 中Web.config文件的读取与写入的更多相关文章
- [转载]C# 中Web.config文件的读取与写入
asp.net2.0新添加了对web.config直接操作的功能.开发的时候有可能用到在web.config里设置配置文件,其实是可以通过程序来设置这些配置节的. asp.net2.0需要添加引用: ...
- C#中web.config文件详解
C#中web.config文件详解 一.认识Web.config文件 Web.config 文件是一个XML文本文件,它用来储存 ASP.NET Web 应用程序的配置信息(如最常用的设置ASP.NE ...
- IOC注入框架——Unity中Web.Config文件的配置与调用
Unity 应用程序块可以从 XML 配置文件中读取配置信息.配置文件可以是 Windows Forms 应用程序的 App.config 或者 ASP.NET 应用程序的 Web.config.当然 ...
- Unity中Web.Config文件的配置与调用
在上一篇文章“Unit简单依赖注入”我们可以实现构造对象和被依赖对象之间的 松耦合,使我们的抽象层(Player)能够保持稳定,但是在并没有把客户类和Player类之间彻底解耦,即当我们不想使用MP3 ...
- 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)
Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...
- .net中Web.config文件的基本原理及相关设置
11.7 使用web.config配置文件 Web配置文件web.config是Web 应用程序的数据设定文件,它是一份 XML 文件,内含 Web 应用程序相关设定的 XML 标记,可以用来简化 ...
- ASP.NET 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)
原文:http://www.cnblogs.com/zhaopei/p/5677053.html
- c#中对txt文件的读取与写入,针对二维数组
class Program { ; ; static string[,] str = new string[ROW, COL]; static void Main(string[] args) { R ...
- Web.Config文件中使用configSource
我们都知道,在asp.net中修改了配置文件web.config后,会导致应用程序重启,所有会话(session)丢失.然而,应用程序的配置信息放在配置文件里是最佳选择,在后台修改了配置后导致所有会话 ...
随机推荐
- flutter image_picker使用照相机
dependencies: image_picker: ^0.4.12+1 最新的^0.5+9编译无法通过 import 'dart:io'; import 'dart:async'; import ...
- Centos6.8 安装nginx
1.安装相关依赖 (1)yum install gcc 备注:可以通过gcc -v 查看版本信息,来确定是否安装过. (2)yum install pcre-devel (3)yum install ...
- linux下使用sha256sum生成sha256校验文件,并校验其一致性
[root@localhost ]# " >test.zip 生成sha256文件校验文件 [root@localhost ]# sha256sum test.zip >test ...
- 莫烦keras学习自修第一天【keras的安装】
1. 安装步骤 (1)确保已经安装了python2或者python3 (2)安装numpy,python2使用pip2 install numpy, python3则使用pip3 install nu ...
- pip 安装 MySQL-python 报错
报错一:EnvironmentError: mysql_config not found 解决:yum install mysql-devel 报错二:Python.h No such file or ...
- 一、linux扩展
1.linux-解压bz2文件提示tar (child): bzip2: Cannot exec: No such file or directory 原因,linux下没有bzip2解压工具 安装b ...
- 五、同一台MySQL服务器启动多个端口-为读写分离做准备
一.安装数据库 https://www.cnblogs.com/huiyi0521/p/10113280.html 二.使用 mysql 命令为 root 用户授权 mysql 远程连接服务 mysq ...
- Xamarin 简化的Android密钥库签名
安装 开始使用这个新工具不容易.在Visual Studio 2017(即将推出VS 2015),只需转到工具 - >扩展和更新,并搜索“密钥库”来查找扩展名. 下载后,只需重新启动Visual ...
- Tcp协议的keepalive功能
L:128
- P1055 书号
P1055 题目描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括99位数字.11位识别码和33位分隔符,其规定格式如x-xxx-xxxxx-x,其中符号-就是分隔符(键盘上的减号 ...