zoukankan      html  css  js  c++  java
  • Source.Library.Common.FileHelper.IniFile

    /**
    * <p>Description: (IniFile)</p>
    * <p>@version 1.0.0</p>
    * <p>Modifaction:(Date-Version-Author-Description)</p>
    * <p>------------------------------------------------------------------------</p>
    */
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.InteropServices;
    namespace Source.Library.Common.FileHelper
    {
        public class IniFile
        {
            public string path;
            public IniFile(string INIPath)
            {
                path = INIPath;
            }
            [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);
            [DllImport("kernel32")]
            private static extern int GetPrivateProfileString(string section, string key, string defVal, Byte[] retVal, int size, string filePath);
            /// <summary>
            /// 写INI文件
            /// </summary>
            /// <param name="Section"></param>
            /// <param name="Key"></param>
            /// <param name="Value"></param>
            public void IniWriteValue(string Section, string Key, string Value)
            {
                WritePrivateProfileString(Section, Key, Value, this.path);
            }
            /// <summary>
            /// 读取INI文件
            /// </summary>
            /// <param name="Section"></param>
            /// <param name="Key"></param>
            /// <returns></returns>
            public string IniReadValue(string Section, string Key)
            {
                StringBuilder temp = new StringBuilder(255);
                int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
                return temp.ToString();
            }
            public byte[] IniReadValues(string section, string key)
            {
                byte[] temp = new byte[255];
                int i = GetPrivateProfileString(section, key, "", temp, 255, this.path);
                return temp;
            }
            /// <summary>
            /// 删除ini文件下所有段落
            /// </summary>
            public void ClearAllSection()
            {
                IniWriteValue(null, null, null);
            }
            /// <summary>
            /// 删除ini文件下personal段落下的所有键
            /// </summary>
            /// <param name="Section"></param>
            public void ClearSection(string Section)
            {
                IniWriteValue(Section, null, null);
            }
        }
    }
  • 相关阅读:
    052-34
    052-33
    052-32
    052-31
    052-30
    052-28
    react组件之间通信
    排序算法
    点外卖
    js的各种排序算法
  • 原文地址:https://www.cnblogs.com/TNTZWC/p/1945452.html
Copyright © 2011-2022 走看看