asp.net 操作INI檔案讀寫類例項程式碼
複製程式碼 程式碼如下:
using System;
using ropServices;
using ;
using ;
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,);
}
///
/// 讀取INI檔案
///
///
///
///
public string IniReadValue(string Section,string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp, 255, );
return ring();
}
public byte[] IniReadValues(string section, string key)
{
byte[] temp = new byte[255];
int i = GetPrivateProfileString(section, key, "", temp, 255, );
return temp;
}
///
/// 刪除ini檔案下所有段落
///
public void ClearAllSection()
{
IniWriteValue(null,null,null);
}
///
/// 刪除ini檔案下personal段落下的所有鍵
///
///
public void ClearSection(string Section)
{
IniWriteValue(Section,null,null);
}
}
}
沒有太多含量,做雕蟲小技是還是用得上。
相關文章
-
asp.net 操作INI檔案讀寫類例項程式碼
複製程式碼 程式碼如下:using System;using ropServices;using ;using ;namespace Common{////// INI檔案讀寫類。///public class INIFile{public string path;public INIFile(string INIPath){path = INIPath;}[DllImpo -
php樹型類例項程式碼
本文例項講述了php樹型類。分享給大家供大家參考。具體分析如下:該例項原理簡單,學過資料結構的'一看就明白是什麼道理了,不過今天在使用時資料中出現了子節點id(71)小於父節點id(104).導致部分子節點沒被儲存入陣列, -
AJAX請求類例項程式碼
都說長髮美女最迷人,這句話一點都不假,這款簡單的長髮髮型,不僅襯托了美女的清新脫俗的氣質,更是將美眉的臉型打造成最有代表性的小V臉,修顏效果非常顯著哦。波浪捲髮的流行,也讓這款髮型多了一份時尚氣息。優雅迷人的盤發 -
C語言中檔案操作詳解及例項程式碼
在檔案操作中除了開啟操作以及讀寫操作,還有幾種比較常見的操作。以下是本站小編搜尋整理的關於這些操作中涉及到的函式,,需要的朋友可以參考本文!想了解更多相關資訊請持續關注我們應屆畢業生考試網! 一.移動位置指 -
PHP中FTP操作類程式碼
文章主要介紹了php中實現FTP功能,包括上傳,拷貝,移動,刪除檔案與建立目錄功能,需要的'朋友可以參考下.就跟隨本站小編一起去了解下吧,想了解更多相關資訊請持續關注我們應屆畢業生考試網! 複製程式碼 程式碼如下:<?php/ -
C語言檔案操作解析詳解及例項程式碼
在檔案操作中除了開啟操作以及讀寫操作,還有幾種比較常見的操作。下面介紹C語言檔案操作解析詳解及例項程式碼,希望大家喜歡! 一.移動位置指標的`函式rewind函式和fseek函式,這兩個函式的原型是:void rewind(FILE *fp); -
ASP.NET連SQL7介面的原始碼
The following example shows what a simple application that connects to the Northwind database and retus a list of Categories would look like. The example writes the output to the console, or command p -
php中使用redis佇列操作例項程式碼
php中使用redis佇列怎麼操作?小編為大家介紹一個php使用redis佇列操作的例子,供初學redis的朋友參考吧。 例1,入隊操作:複製程式碼 程式碼如下:<?php$redis = new Redis();$redis->connect('',6379);while(True){t -
asp.net 組合模式的PHP程式碼
複製程式碼 程式碼如下:using System;using ric;using ;using ;namespace Test{class Program{static void Main(string[] args){var customer = new Customer{IsActive = true,LateFees = 100M,TotalRentNumber = 10};eL -
C語言以資料塊的形式讀寫檔案例項程式碼
大家知道C語言怎麼以資料塊的形式讀寫檔案嗎?下面小編為大家整理了C語言以資料塊的形式讀寫檔案例項程式碼,希望能幫到大家!fgets() 有侷限性,每次最多隻能從檔案中讀取一行內容,因為 fgets 遇到換行符就結束讀取。如果希望