ini文件一般用于保存当前运行的程序或者一些临时的配置属性的文件。也有时用于保存一定的数据以便于临时或者配置上的需要。
文本格式如下:
[Section1 Name] ---------用 []括起来,其包含多个key
KeyName1=value1 ------格式是 Key=value。
KeyName2=value2
...
[Section2 Name]
KeyName1=value1
KeyName2=value2
其中有专门读写ini文件的windows方法:
[DllImport("kernel32")]
// 写入ini文件操作section,key,value
private static extern long WritePrivateProfileString(string section,string key, string val, string filePath);
[DllImport("kernel32")]
// 读取ini文件操作section,key,和返回的keyvalue
private static extern int GetPrivateProfileString(string section,string key, string def, StringBuilder retVal,int size, string filePath);
C#操作时代码如下:
640

被折叠的 条评论
为什么被折叠?



