zoukankan      html  css  js  c++  java
  • 获取配置文件中的key的value

    获取App.config文件的key的value

    System.Configuration.ConfigurationManager.AppSettings["keyName"]

    获取web.config文件的key的value

    ConfigurationManager.AppSettings["keyName"];

    获取web.config文件的connectString

    ConfigurationManager.ConnectionStrings["connectName"].ConnectionString;

    配置文件:

    ①App.Config

     1 <?xml version="1.0"?>
     2 <configuration>
     3   <configSections>
     4     <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
     5       <section name="Quartz_TimerJob.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     6     </sectionGroup>
     7   </configSections>
     8   <appSettings>
     9     <add key="keyName" value="key's Value" />
    10 <!-- 多个key value组合-->
    11 </appSettings>
    12 </configuration>

    ②Web.config

    key value部分 同上,没多少差

    connectString 部分如下

    <connectionStrings>
        <add name="LGFZDataLayer.Properties.Settings.XXConnectionString" connectionString="Data Source=10.***.*.***;Initial Catalog=XX;User ID=sa;Password=12345678" providerName="System.Data.SqlClient" />
      </connectionStrings>
  • 相关阅读:
    [转]ANDROID JNI之JAVA域与c域的互操作
    android 管理Touch事件
    android gesture检测
    android 数据库操作
    android 文件保存
    【转】Android 添加系统服务
    【转】android makefile文件分析
    vlc 编译
    oracle to_date 函数
    ORACLE分页SQL语句(转载)
  • 原文地址:https://www.cnblogs.com/tldxh/p/7153832.html
Copyright © 2011-2022 走看看