zoukankan      html  css  js  c++  java
  • c# ini文件操作

    public class INIConfigHelper
        {
            public string Path;     //INI文件名
            [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文件的API函数     
            public INIConfigHelper(string iniPath)
            {
                Path = iniPath;
            }
    
            //类的构造函数,传递INI文件名
            public void IniWriteValue(string section, string key, string value)
            {
                WritePrivateProfileString(section, key, value, this.Path);
            }
    
            //读INI文件         
            public string IniReadValue(string section, string key)
            {
                var temp = new StringBuilder(256);
                int i = GetPrivateProfileString(section, key, "", temp, 256, this.Path);
                return temp.ToString();
            }
        }
    private INIConfigHelper configReader = new INIConfigHelper(string.Concat(AppDomain.CurrentDomain.BaseDirectory, "Config\Counter.ini"));
    读取节点:
    string section = "time";
                    string startTimeStr = configReader.IniReadValue(section, "start");
    更新节点:
    configReader.IniWriteValue("time", "start", maxTime.ToString("yyyy-MM-dd HH:mm:ss"));
  • 相关阅读:
    jQuery使用手册之Ajax支持(8)
    jQuery使用手册之动态效果(6)
    jquery插件 操作select
    提高jQuery的性能
    jQuery起点教程之使用AJAX(4)
    jQuery起点教程之插件制作(7)
    IE开发工具栏
    信息安全之DNS欺骗详解
    颜色取色器
    使DIV不被select等控件遮挡的解决办法
  • 原文地址:https://www.cnblogs.com/zengwei/p/10981745.html
Copyright © 2011-2022 走看看