zoukankan      html  css  js  c++  java
  • .net 2.0 里面操作配置文件 的问题 (读取另外的配置文件的时候的疑问)

    有一个问题,遍寻网上而不见.

    在vs2005中,如果不读取默认的app.config文件,而是读取自定义的配置文件.

    需要用system.configuration.configuration a=configurationmanager.openexeconfiguration(配置文件路径);

    然后我获取appsettings,

    string appPath = System.Windows.Forms.Application.StartupPath;
                
    string configPath = appPath + "\\DocAddin.dll.config";
                System.Configuration.Configuration config
    = System.Configuration.ConfigurationManager.OpenExeConfiguration(configPath);            

                
    string dbPath=config.AppSettings.Settings["DBPath"].Value;

     结果发现appsettings的settings集合里面是空的.根本一个键值对都没有.

    我的config文件里面是这样定义的

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <appSettings>    
          
    <add key="DBPath" value="D:\Program Files\默认公司名称\SetupForDocAddin\DOCDB.mdb"/>
          
    <add key="MachineID" value="DefaultMachine"/>      
      
    </appSettings>
    </configuration>

    最后发现:
     ConfigurationSettings .AppSettings
    ConfigurationManager.AppSettings
    Configuration.AppSettings.都不一样 .

    正在继续研究中 .
  • 相关阅读:
    ionic 白名单
    简单的apk Ionic
    Ionic 小节
    Ionic学习笔记四 一些问题处理
    Android Platform Guide
    Android各个版本 版本号对应关系表
    JBPM4.4_管理流程定义
    JBPM4.4_核心概念与相关API
    工作流JBPM_day01:3-使用JBPM的API添加与执行流程
    工作流JBPM_day01:2-HelloWorld
  • 原文地址:https://www.cnblogs.com/telephoner/p/809374.html
Copyright © 2011-2022 走看看