[.net]ini文件操作 |
执著 发表于 2005/4/11 13:17:13 |
| using System;using System.IO;using System.Runtime.InteropServices;using System.Text;
public class inifile { public string Path; [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);
public inifile(string filename) { // // TODO: 在此处添加构造函数逻辑 // Path = filename; }
public void IniWriteValue(string Section,string Key,string Value) { WritePrivateProfileString(Section,Key,Value,this.Path); }
public string IniReadValue(string Section,string Key) { StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString(Section,Key,"",temp,255,this.Path); return temp.ToString(); } } | |
|
|
|