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請求類實例代碼
聽見了嗎?那洶涌澎湃發出撕心裂肺叫聲的是那片海!看到了嗎?那廣闊無垠一眼望不到邊的那一片藍也正是那海!今天,我孤身一人來到海邊,見到了我心中那一片既熟悉又陌生的汪洋大海。我對它充滿好奇,又充滿了無盡的恐懼。我在海邊 -
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 遇到換行符就結束讀取。如果希望