您的位置:首页 > 编程语言 > C#

c#操作web.config

2014-04-29 13:08 351 查看
web.config文件
<appSettings>

<!--<add key="YZTUrl"value="http://WIN-IAOS1A1SO7O/mapsystemweb/index.aspx" />-->

<add key="YZTUrl"value="http://win-iaos1a1so7o:8171/MapSystem.Web_SQLSERVER/Default.aspx"/>

<add key="PageSize" value="10" />

<add key="DBLX" value="1"/>

<add key="XZQ" value="450700"/>

<!-- 数据库类型 1 SQL Server 2 ORACLE -->

<add key="Server"value="GTSERVERCP\GTCP2005"/>
</appSettings>

读取vs2012中,<appsetings>节点

DB_META.Value =System.Configuration.ConfigurationManager.AppSettings["DB_META"];

修改<appseting>中的值

List<XElement> addSets = (from t in xelement.Descendants("add") select t).ToList();
addSets[10].Attribute("value").Value= txtYZTUrl.Value;

web.config文件
<applicationSettings>

<DZManagerSystem.Properties.Settings>

<!--一张图的自定义服务-->

<setting name="DZManagerSystem_EditService_EditService"serializeAs="String">

<value>http://win-iaos1a1so7o:8070/CustomService_ORACLE/services/EditService.EditServiceHttpSoap11Endpoint/</value>

</setting>

</DZManagerSystem.Properties.Settings>
</applicationSettings>

读取<applicationSettings>节点

YZTCustomServeice.Value =
DZManagerSystem【项目名称】.Properties.Settings.Default.Properties["DZManagerSystem_EditService_EditService"].DefaultValue.ToString();

修改<applicationSettings>节点

List<XElement> sets = (from tin xelement.Descendants("value") select t).ToList();
sets[2].Value =txtYZTCustomServeice.Value;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: