zoukankan      html  css  js  c++  java
  • ini文件读取

    public class IniConfigHelp
    {
    [DllImport("kernel32")]
    private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);
    [DllImport("kernel32")]
    private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);


    //ini文件名称
    private static string inifilename = "Config.ini";
    //CS客户端获取ini文件路径
    private static string inifilepath = Application.StartupPath + "\" + inifilename;
    //Web端获取ini文件路径
    //private static string inifilepath = (Directory.GetCurrentDirectory().ToUpper().IndexOf("IIS") != -1 || Directory.GetCurrentDirectory().ToUpper().IndexOf("C:") != -1) ? HttpRuntime.AppDomainAppPath + "\" + inifilename : Application.StartupPath + "\" + inifilename;

    /// <summary>
    /// 获取节点的值
    /// </summary>
    /// <param name="mname">大节点</param>
    /// <param name="key">值名称</param>
    /// <returns></returns>
    public static string GetValue(string mname, string key)
    {

    StringBuilder s = new StringBuilder(1024);
    GetPrivateProfileString(mname, key, "", s, 1024, inifilepath);
    return s.ToString();
    }

    //获取值

      String product = IniConfigHelp.GetValue("A", "appid");
    }

  • 相关阅读:
    堆排序
    阿里云
    ubuntu下编译内核模块
    字节对齐
    线段树
    c++虚函数表解析
    电面
    sql server数据库定时自动备份
    [hiho1584]Bounce
    五彩斑斓的世界
  • 原文地址:https://www.cnblogs.com/AbelAngelo/p/13229067.html
Copyright © 2011-2022 走看看