读写ini文件代码

读写ini文件的两个函数

WritePrivateProfileString();//写入
WritePrivateProfileString(string section,string key,string val,string filePath);
参数解释
section  小结名
key 关键字
val 值
filePath 文件路径

GetPrivateProfileString();//读取
GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
参数解释
section  小结名
key 关键字
def 指定条目没找到的时返回的默认值
retVal   指定的字符缓冲区
size     retVal缓冲区最大字符数量
filePath 文件路径
使用的时候需要引入
using System.Runtime.InteropServices;

代码示例
Code
posted @ 2009-09-23 14:34  fsl  阅读(289)  评论(0编辑  收藏  举报