asp.net 操作INI文件讀寫(xiě)類實(shí)例代碼

    時(shí)間:2024-07-28 17:24:04 ASP 我要投稿
    • 相關(guān)推薦

    asp.net 操作INI文件讀寫(xiě)類實(shí)例代碼

      復(fù)制代碼 代碼如下:

      using System;

      using System.Runtime.InteropServices;

      using System.Text;

      using System.IO;

      namespace Common

      {

      ///

      /// INI文件讀寫(xiě)類。

      ///

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

      ///

      /// 寫(xiě)INI文件

      ///

      ///

      ///

      ///

      public void IniWriteValue(string Section,string Key,string Value)

      {

      WritePrivateProfileString(Section,Key,Value,this.path);

      }

      ///

      /// 讀取INI文件

      ///

      ///

      ///

      ///

      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;

      }

      ///

      /// 刪除ini文件下所有段落

      ///

      public void ClearAllSection()

      {

      IniWriteValue(null,null,null);

      }

      ///

      /// 刪除ini文件下personal段落下的所有鍵

      ///

      ///

      public void ClearSection(string Section)

      {

      IniWriteValue(Section,null,null);

      }

      }

      }

      沒(méi)有太多含量,做雕蟲(chóng)小技是還是用得上。

    【 asp.net 操作INI文件讀寫(xiě)類實(shí)例代碼】相關(guān)文章:

    php解析ini配置文件07-13

    ASP.NET MVC異常處理模塊簡(jiǎn)單教程-ASP.NET教程實(shí)例推薦07-19

    ASP.NET連SQL7接口的源代碼06-06

    Java文件解壓縮實(shí)例詳解201607-26

    Linux文件系統(tǒng)操作命令大全07-03

    關(guān)于ASP.NET使用JavaScript顯示信息提示窗口實(shí)現(xiàn)原理及代碼05-09

    ASP網(wǎng)頁(yè)程序設(shè)計(jì)中10個(gè)非常有用的實(shí)例代碼08-12

    Linux操作系統(tǒng)文件系統(tǒng)基礎(chǔ)知識(shí)07-25

    2016職稱英語(yǔ)綜合類A代碼12考試答案09-14

    Mac電腦設(shè)置自動(dòng)排列文件圖標(biāo)的操作方法07-04

    91久久大香伊蕉在人线_国产综合色产在线观看_欧美亚洲人成网站在线观看_亚洲第一无码精品立川理惠

      好吊妞在线观看新免费视频 | 五色天婷婷丁香五月综合 | 日韩精品一区二区在线 | 亚洲国产免费综合网 | 亚洲国产人午夜在线 | 思思久久96re|