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");
    }

  • 相关阅读:
    第二次冲刺 03
    第二次冲刺 02
    第二次冲刺 01
    程序员修炼三部曲阅读笔记03
    程序员修炼三部曲阅读笔记02
    团队项目计划会议
    课堂练习—购书
    构建之法阅读笔记03
    学习进度条十二
    课堂作业找水王2
  • 原文地址:https://www.cnblogs.com/AbelAngelo/p/13229067.html
Copyright © 2011-2022 走看看