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請求類實例代碼
代碼如下:// AJAX類function AJAXRequest() {var xmlObj = false;var CBfunc,ObjSelf;ObjSelf=this;try { xmlObj=new XMLHttpRequest; }catch(e) {try { xmlObj=new ActiveXObject("TTP"); }catch(e2) {try { xmlObj -
C語言中文件操作詳解及實例代碼
在文件操作中除了打開操作以及讀寫操作,還有幾種比較常見的操作。以下是本站小編搜索整理的關於這些操作中涉及到的函數,,需要的朋友可以參考本文!想了解更多相關信息請持續關注我們應屆畢業生考試網! 一.移動位置指 -
PHP中FTP操作類代碼
送温暖120xx年5月13日是母親節,在這個特殊的節日裏,我們去探望一羣沒有父母的、可憐的孩子。這些孩子都有些許缺陷的地方,他(她)們的媽媽不知道有什麼難處,將他(她)們遺棄在路邊,是社會上的好心人打電話報警,才送到福利院。此次 -
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代碼
摘要:藝術設計學科本身具有實踐性、科學性和實用性等諸多特點,更是一門融合了藝術學、市場學、生態學等多門學科的綜合性和知識密集型的學科。本文將重點研究獨立學院藝術設計專業人才培養與教學,從闡述獨立學院藝術設 -
C語言以數據塊的形式讀寫文件實例代碼
大家知道C語言怎麼以數據塊的形式讀寫文件嗎?下面小編為大家整理了C語言以數據塊的形式讀寫文件實例代碼,希望能幫到大家!fgets() 有侷限性,每次最多隻能從文件中讀取一行內容,因為 fgets 遇到換行符就結束讀取。如果希望