c#操作web.config

来源:互联网 发布:雨人f4软件常见问题 编辑:程序博客网 时间:2024/06/09 03:49

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;

 

0 0
原创粉丝点击