C#读取ini文件方法,实质是使用C++的库
2016-01-28 19:54
711 查看
C#读取ini文件方法,实质是使用C++的库
[DllImport("kernel32")] public static extern long WritePrivateProfileString(string section, string key, string val, string filepath); [DllImport("kernel32")] public static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);
//读取ini配置文件 public static string GetIniValue(string strFilePath, string key) { if (!File.Exists(strFilePath)) return string.Empty; StringBuilder temp = new StringBuilder(1024); string strSec = "GISDownLoad"; HVIC.Library.Win32API.GetPrivateProfileString(strSec, key, "", temp, 1024, strFilePath); return temp.ToString(); } //写入ini配置文件 public static void WriteIniValue(string strFilePath,string key,string value) { string strSec = "GISDownLoad"; if (!string.IsNullOrEmpty(value)) { HVIC.Library.Win32API.WritePrivateProfileString(strSec, key, value.Trim(), strFilePath); } }
相关文章推荐
- __asm__ volatile 之 C语言嵌入式汇编
- C++的一些笔记
- 小蚂蚁学习C语言(37)——题目——求出1000以内的所有完数以及它的因子
- 将C语言宏定义转换成字符串!
- C++11 特性了解
- 20160127.CCPP体系详解(0006天)
- c++ 中 class 和 struct 的区别是什么
- 五种常用的C/C++编译器对64位整型的支持
- C++利用智能指针shared_ptr实现对象池
- C++:const和引用
- C语言基础之scanf缓冲区
- C语言open()函数:打开文件函数
- C++学习之多态篇(多态的几个特点)
- leetcode刷题系列C++-Search in Rotated Sorted Array
- 浅谈C++中内存分配、函数调用和返回值问题
- 浅谈C++中指针和引用的区别
- C/C++ ASCII码表
- 关于C语言链表的学习
- c++ 内联函数 (讲解的TM真好)
- 什么是C语言局部程序块(local block)