zoukankan      html  css  js  c++  java
  • winform 项目获取app.config 中appSettings节点数据

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
                <section name="StartUpgrade.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            </sectionGroup>
        </configSections>
      <appSettings>
        <!-- checkin 文件夹和文件名 -->
        <add key="checkin-filefolder" value="D:NotePad++"/>
        <add key="checkin-filefolder-name" value="npp.6.1.3.Installer.exe"/>
        
        <!-- 出钞 文件夹和文件名 -->
        <add key="outmoney-filefolder" value="D:NotePad++"/>
        <add key="outmoney-filefolder-name" value="npp.6.1.3.Installer.exe"/>
        
        <!-- 入钞 文件夹和文件名 -->
        <add key="inmoney-filefolder" value="D:NotePad++"/>
        <add key="inmoney-filefolder-name" value="npp.6.1.3.Installer.exe"/>
        
        <!-- 字节数组 -->
        <add key="bytearrary" value="10240"/>
        <add key="upload-path" value="E:ProjectsHotelsStartUpgradeStartUpgradeFile"/>
        <add key="upload-url" value="http://192.168.1.200:8077/UpgradeFiles/"/>
      </appSettings>
        <system.serviceModel>
          <bindings />
          <client />
        </system.serviceModel>
        <applicationSettings>
          <StartUpgrade.Properties.Settings>
                <setting name="StartUpgrade_IStartUpgrade_UpgradeFile" serializeAs="String">
                    <value>http://192.168.1.155:8013/DataService/WebService/Interface/UpgradeFile.asmx</value>
                </setting>
            </StartUpgrade.Properties.Settings>
        </applicationSettings>
     
    </configuration>

    然后在winform中cs文件里这样调用:

            /// <summary>
            /// 获取配置文件里appsettings的数据
            /// </summary>
            /// <param name="str"></param>
            /// <returns></returns>
            public string GetAppsettingStr(string str)
            {
                AppSettingsReader appReader = new AppSettingsReader();
                return appReader.GetValue(str, typeof(string)).ToString();
            }
  • 相关阅读:
    tomcat启动项目,起不起来
    jQuery ajax 获取信息展示在“下拉列表”中
    JQuery,ajax,jsonp 跨域访问
    httpwebrequest详解
    利用HttpWebRequest和HttpWebResponse获取Cookie并实现模拟登录
    C# 中使用System.Net.Http.HttpClient 模拟登录博客园 (GET/POST)
    JAVA-用HttpClient来模拟浏览器GET,POST
    java 实现模拟浏览器 访问网站
    ora-01017 和oracle database link
    JDeveloper 开发环境配置
  • 原文地址:https://www.cnblogs.com/zhangwei595806165/p/3517603.html
Copyright © 2011-2022 走看看