zoukankan      html  css  js  c++  java
  • 从网上找的配置文件类,比我原来的好,能用在winform和webform项目中

    能用在两种项目中,比较不错
    using System;
    using System.Configuration;
    using System.Reflection;
    using System.Web;
    using System.Xml;

    public enum ConfigFileType


    namespace TexSelect
    {
        
    /**//// <summary>
        
    /// 配置文件操作类
        
    /// </summary>

        public class AppConfig : AppSettingsReader
        

    }

    使用方法:
    string sqlConnText="";

                AppConfig appconfig
    =new AppConfig();
                appconfig.ConfigType
    =(int)ConfigFileType.WebConfig;

                sqlConnText
    =(string)appconfig.GetValue("SQLConnectionString",sqlConnText.GetType());

    设置方法:
    项目为web项目,则配置信息存在web.config文件中,使用时:appconfig.ConfigType=(int)ConfigFileType.WebConfig;
    项目为win项目,则配置信息存在app.config文件中,使用时:appconfig.ConfigType=(int)ConfigFileType.AppConfig;

    配置文件示例:
    不论在web.config中还是在app.config中都放在<configuration></configuration>之间,格式如下:
     <appSettings>

         
    <add key="SQLConnectionString" value="Server=127.0.0.1;database=tex;uid=sa;pwd=sa" />
             
      
    </appSettings>

  • 相关阅读:
    (转) SpringBoot非官方教程 | 第一篇:构建第一个SpringBoot工程
    Swagger2 生成 Spring Boot API 文档
    tar命令解压时如何去除目录结构及其解压到指定目录 (--strip-components N)
    Alpine Linux配置使用技巧【一个只有5M的操作系统(转)】
    配置Tomcat直接显示目录结构和文件列表
    React package.json详解
    Ubuntu中的“资源管理器”System Monitor
    Ubuntu18.10下安装Qt5.12过程记录
    QT QTransform与QMatrix 有啥区别?
    QT运行出错:QObject::connect: Parentheses expected以及QObject::connect: No such slot ***
  • 原文地址:https://www.cnblogs.com/telephoner/p/236929.html
Copyright © 2011-2022 走看看