读写INI文件DEMO

时间:2015-07-20 09:08:47
【文件属性】:
文件名称:读写INI文件DEMO
文件大小:59KB
文件格式:RAR
更新时间:2015-07-20 09:08:47
C#、ini C#实现对ini文件的读取和写入操作 public string 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); /// /// 构造方法 /// /// 文件路径 public INIClass(string INIPath) { inipath = INIPath; } /// /// 写入INI文件 /// /// 项目名称(如 [TypeName] ) /// 键 /// 值 public void IniWriteValue(string Section, string Key, string Value) { WritePrivateProfileString(Section, Key, Value, this.inipath); } /// /// 读出INI文件 /// /// 项目名称(如 [TypeName] ) /// 键 public string IniReadValue(string Section, string Key) { StringBuilder temp = new StringBuilder(500); int i = GetPrivateProfileString(Section, Key, "", temp, 500, this.inipath); return temp.ToString(); } /// /// 验证文件是否存在 /// /// 布尔值 public bool ExistINIFile() { return File.Exists(inipath); }
【文件预览】:
读写INI文件DEMO
----WindowsApplication1()
--------Form1.Designer.cs(3KB)
--------Program.cs(478B)
--------obj()
--------bin()
--------Form1.cs(817B)
--------Form1.resx(6KB)
--------INI.csproj(3KB)
--------INIClass.cs(2KB)
--------Properties()
----WindowsApplication1.sln(914B)
----WindowsApplication1.suo(25KB)

网友评论

  • 中文注释 Code写的。。。