本站首页    管理页面    写新日志    退出

The Neurotic Fishbowl

[学习公共库]INI文件用法
麦林 发表于 2008/10/20 13:37:21

public class INIClass    {        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);        /// <summary>        /// 构造方法        /// </summary>        /// <param name="INIPath">文件路径</param>        public INIClass(string INIPath)        {            inipath = INIPath;        }        /// <summary>        /// 写入INI文件        /// </summary>        /// <param name="Section">项目名称(如 [TypeName] )</param>        /// <param name="Key">键</param>        /// <param name="Value">值</param>        public void IniWriteValue(string Section, string Key, string Value)        {     //若需删除某个项,把Value改为Null即可            WritePrivateProfileString(Section, Key,Value,this.inipath);        }        /// <summary>        /// 读出INI文件        /// </summary>        /// <param name="Section">项目名称(如 [TypeName] )</param>        /// <param name="Key">键</param>        public string IniReadValue(string Section, string Key)        {            StringBuilder temp = new StringBuilder(500);            int i = GetPrivateProfileString(Section, Key, "", temp, 500, this.inipath);            return temp.ToString();        }        /// <summary>        /// 验证文件是否存在        /// </summary>        /// <returns>布尔值</returns>        public bool ExistINIFile()        {            return System.IO.File.Exists(inipath);        }         /// <summary>        /// 删除文件        /// </summary>        public void DeleteFile()        {            System.IO.File.Delete(inipath);        }    }

阅读全文(5781) | 回复(0) | 编辑 | 精华

 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)
 

The Neurotic Fishbowl

.: 公告

fighting for the work!


Bloginess

«September 2025»
123456
78910111213
14151617181920
21222324252627
282930

.: 我的分类(专题)

首页(449)
文字感悟(103)
学习公共库(61)
生活体会(100)
资源收集(14)
.NET-Winform(27)
音乐文字(15)
心情小记(119)
SQL问题解决(10)


In the Bowl

.: 最新日志

C#打印代码
你看到的我是蓝色的
即将逝去的3月
这个假期
两个月过去
表名存在其他表时获取数据
条码打印
Remoting的用法
INI文件用法


.: 最新回复

回复:条码打印
回复:条码打印
回复:即将逝去的3月
回复:cookie对象使用
回复:条码打印
回复:JSP学习(字符串比较)
回复:应收应付核销规则及常见问题(续)
回复:两个月过去
回复:两个月过去


The Fishkeeper
blog名称:栗色?蓝色?
日志总数:449
评论数量:201
留言数量:37
访问次数:2259827
建立时间:2006年5月16日



Text Me

.: 留言板

签写新留言

链接完成
回:loseVC
来喽~
转转......
新年啦
对自己说
祝福
回:佑手
WO


Other Fish in the Sea

.: 链接


loseVC's BLOG
Collapsar_feel
布衣加针
C#and.Net
Kinogam Web




站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.063 second(s), page refreshed 144760609 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号