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

  • 相关阅读:
    A bon chat, bon rat
    获取信息mysql
    Lua笔记3 表达式
    libevent2编译
    opencv环境搭建
    bash console
    Unix Notes.
    ubuntu vsftpd
    axis2客户端代码生成
    IDEA 快捷键
  • 原文地址:https://www.cnblogs.com/AbelAngelo/p/13229067.html
Copyright © 2011-2022 走看看