天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

ASP.NET(C#)應(yīng)用程序配置文件app.config/web.config的增、刪、改操作

配置文件,對于程序本身來說,就是基礎(chǔ)和依據(jù),其本質(zhì)是一個(gè)xml文件,對于配置文件的操作,從.NET 2.0 開始,就非常方便了,提供了 System [.Web] .Configuration 這個(gè)管理功能的NameSpace,要使用它,需要添加對 System.configuration.dll的引用。
對于WINFORM程序,使用 System.Configuration.ConfigurationManager;
對于ASP.NET 程序, 使用 System.Web.Configuration.WebConfigurationManager;
對于配置文件內(nèi)容的讀取,真是太普遍不過了,如果你的程序里,沒有讀取配置文件內(nèi)容的方面,你都不好意思拿出來用
我們以最常見的 AppSettings 小節(jié)來作為例子:
假設(shè)有如下的配置文件內(nèi)容:
復(fù)制代碼 代碼如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="y" value="this is Y"/>
</appSettings>
</configuration>

1. 讀取值:
* ASP.NET: System.Web.Configuration.WebConfigurationManager.AppSettings[“y”];
* WinForm: System.Configuration.ConfigurationManager.AppSettings[“y”];
2. 添加一項(xiàng)
ASP.NET(需要有寫權(quán)限):
Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
AppSettingsSection app = config.AppSettings;
app.Settings.Add("x", "this is X");
config.Save(ConfigurationSaveMode.Modified);
WinForm:
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection app = config.AppSettings;
app.Settings.Add("x", "this is X");
config.Save(ConfigurationSaveMode.Modified);
3. 修改一項(xiàng)
* ASP.NET
Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
AppSettingsSection app = config.AppSettings;
//app.Settings.Add("x", "this is X");
app.Settings["x"].Value = "this is not Y";
config.Save(ConfigurationSaveMode.Modified);
* WinForm
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection app = config.AppSettings;
//app.Settings.Add("x", "this is X");
app.Settings["x"].Value = "this is not Y";
config.Save(ConfigurationSaveMode.Modified);
4. 刪除一項(xiàng)
* ASP.NET
Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
AppSettingsSection app = config.AppSettings;
app.Settings.Remove("x");
config.Save(ConfigurationSaveMode.Modified);
* WinForm
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection app = config.AppSettings;
app.Settings.Remove("x");
config.Save(ConfigurationSaveMode.Modified);

AspNet技術(shù)ASP.NET(C#)應(yīng)用程序配置文件app.config/web.config的增、刪、改操作,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 老阿姨儿子一二三区 | 理论片午午伦夜理片2021 | 日韩做A爰片久久毛片A片毛茸茸 | 99久久久免费精品免费 | 久cao在线香蕉 | 黑丝美女娇喘 | 白丝女仆被强扒内裤 | 亚洲国产精品线在线观看 | 台湾佬休闲中性娱乐网 | 麻豆成人AV久久无码精品 | 息与子在线交尾中文字幕 | 国产精品久久久久AV麻豆 | 国产人妻人伦精品1国产 | 日本一区不卡在线播放视频免费 | 快播电影频道 | 伦理片92伦理午夜 | 琪琪伦伦影院理论片 | 午夜AV国产欧美亚洲高清在线 | 精品国产乱码久久久久久口爆 | 麻豆精品传媒卡一卡二传媒短视频 | 阿片在线播放 | 99久久无码一区人妻A片蜜 | 久久精品一区二区三区资源网 | 亚洲色婷婷久久精品AV蜜桃久久 | 向日葵视频app下载18岁以下勿看 | 国产香蕉尹人视频在线 | xxx性欧美在线观看 xxx性欧美在线 | 色戒2小时38分在线观看 | 和美女啪啪啪动态图 | 龙广在线收听 | 不卡一区二区高清观看视频 | 九九热在线视频观看这里只有精品 | 男生在床上脱美女 胸 | u15女少天堂写真 | 污文啊好棒棒啊好了 | 秘密影院久久综合亚洲综合 | 97视频免费观看2区 97视频免费观看 | 色呦呦人人视频 | 免费99精品国产自在现线 | 9LPORM原创自拍达人 | 777精品久无码人妻蜜桃 |