/// <summary>
/// Ini文件操作类
/// </summary>
public class Ini
{
// 声明INI文件的写操作函数 WritePrivateProfileString()
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); // 声明INI文件的读操作函数 GetPrivateProfileString()
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, System.Text.StringBuilder retVal, int size, string filePath); private string sPath = null;
/// <summary>
/// Ini文件的完整路径
/// </summary>
/// <param name="path"></param>
public Ini(string path)
{
this.sPath = path;
} /// <summary>
/// 向ini文件内写入
/// </summary>
/// <param name="section">配置节点名</param>
/// <param name="key">键名</param>
/// <param name="value">键值</param>
public void Writue(string section, string key, string value)
{
// section=配置节,key=键名,value=键值,path=路径
WritePrivateProfileString(section, key, value, sPath);
} /// <summary>
/// 读取ini文件制定节点的值
/// </summary>
/// <param name="section">配置节点名</param>
/// <param name="key">键值</param>
/// <returns>值</returns>
public string ReadValue(string section, string key)
{
// 每次从ini中读取多少字节
System.Text.StringBuilder temp = new System.Text.StringBuilder();
// section=配置节,key=键名,temp=上面,path=路径
GetPrivateProfileString(section, key, "", temp, , sPath);
return temp.ToString();
}
}

Ini文件操作类的更多相关文章

  1. 读写INI文件操作类

    详情介绍:http://zh.wikipedia.org/wiki/INI%E6%96%87%E4%BB%B6 示例: 下面是一个虚拟的程序,其INI文件有两个小节,前面的小节是用来设置拥有者的信息, ...

  2. C# ini配置文件操作类

    /// <summary> /// INI文件操作类 /// </summary> public class IniFileHelper { /// <summary&g ...

  3. 【个人使用.Net类库】(1)INI配置文件操作类

    开发接口程序时,对于接口程序配置的IP地址.端口等都需要是可配置的,而在Win Api原生实现了INI文件的读写操作,因此只需要调用Win Api中的方法即可操作INI配置文件,关键代码就是如何调用W ...

  4. C# 文件操作类大全

      C# 文件操作类大全 时间:2015-01-31 16:04:20      阅读:1724      评论:0      收藏:0      [点我收藏+] 标签: 1.创建文件夹 //usin ...

  5. ini文件操作

    Config.ini 文件操作 [SYS] sysname=hy company=hyhy tel=2 using System; using System.Collections.Generic; ...

  6. ini 文件操作记要(1): 使用 TIniFile

    ini 文件操作记要(1): 使用 TIniFile unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Class ...

  7. winform INI文件操作辅助类

    using System;using System.Runtime.InteropServices;using System.Text; namespace connectCMCC.Utils{ // ...

  8. [C#] 常用工具类——文件操作类

    /// <para> FilesUpload:工具方法:ASP.NET上传文件的方法</para> /// <para> FileExists:返回文件是否存在&l ...

  9. [IO] C# INI文件读写类与源码下载 (转载)

    /// <summary> /// 类说明:INI文件读写类. /// 编 码 人:苏飞 /// 联系方式:361983679 /// 更新网站:[url]http://www.sufei ...

随机推荐

  1. wxpython 树形控件全选和取消全选

    #encoding:utf-8 import wx import wx.lib.agw.customtreectrl as CT class MyFrame(wx.Frame): def __init ...

  2. Item with the same id "98" already exist

    在magento项目中多次遇到这样一个错误: Item (Bluecom_Onefieldusername_Model_Customer) with the same id "98" ...

  3. 【Leetcode】Same Tree

    给定两棵二叉树,判断是否相等(即树的结构以及各结点中的值都一样) Given two binary trees, write a function to check if they are equal ...

  4. C++中使用class和structkeyword的不同

    类能够在它的第一个訪问说明符之前定义成员,对这样的成员的訪问权限依赖于类定义的方式.假设我们使用structkeyword,则定义在第一个訪问说明符之前的成员是public的,相反,假设使用class ...

  5. iphone--有关日历中NSDateFormatter中英文

    在使用日历使用中,获取星期的时候 NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFo ...

  6. CSS的W3C标准的盒子模型和低版本IE浏览器的盒子模型

    CSS中盒子模型的组成由内容区(content).内边距(padding).边框(border).外边距(margin)组成.内边距可细分为 padding-top.padding-right.pad ...

  7. Can't load IA 32-bit .dll on a AMD 64-bit platform

    在myeclipse中使用的,tomcat异常:java.lang.UnsatisfiedLinkError: D:\JAVA\ApacheTomcat\bin\tcnative-1.dll: Can ...

  8. Invalid signature file digest for Manifest main attributes

    Solving a Spark error: Invalid signature file digest for Manifest main attributes When using spark-s ...

  9. 航频卫士APP截图

  10. CreateFileMapping共享内存时添加Global的作用

    来源:http://www.cnblogs.com/elvislogs/articles/ShareMemory.html 通常使用CreateFileMapping建立共享内存时名称中没有加入&qu ...