亚洲国产日韩欧美在线a乱码,国产精品路线1路线2路线,亚洲视频一区,精品国产自,www狠狠,国产情侣激情在线视频免费看,亚洲成年网站在线观看

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

時(shí)間:2020-11-12 15:09:01 ASP 我要投稿

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

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

  using System;

  using System.Runtime.InteropServices;

  using System.Text;

  using System.IO;

  namespace Common

  {

  ///

  /// INI文件讀寫類。

  ///

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

  ///

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

  }

  }

  }

  沒有太多含量,做雕蟲小技是還是用得上。

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

1.AJAX請(qǐng)求類實(shí)例代碼

2.php樹型類實(shí)例代碼

3.php解析ini配置文件

4.asp.net 組合模式的PHP代碼

5.jquery異步請(qǐng)求的實(shí)例代碼

6.asp獲取當(dāng)前URL代碼實(shí)例

7.關(guān)于AJAX類代碼

8.asp緩存類代碼