public class INIoperation
{
string inipath = Utils.GetMapPath("/Integration/Sync/set.ini");
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
/// <summary>
/// 读取配置ini文件
/// </summary>
/// <param name="Section">配置段</param>
/// <param name="Key">键</param>
/// <param name="innpath">存放物理路径</param>
/// <returns></returns>
public string IniReadValue(string Section, string Key, string innpath)
{
StringBuilder temp = new StringBuilder();
GetPrivateProfileString(Section, Key, "", temp, , inipath);
return temp.ToString();
}
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
/// <summary>
/// 写入ini文件的操作
/// </summary>
/// <param name="Section">配置段</param>
/// <param name="Key">键</param>
/// <param name="Value">键值</param>
/// <param name="inipath">物理路径</param>
public void IniWriteValue(string Section, string Key, string Value,string inipath)
{
WritePrivateProfileString(Section, Key, Value, inipath);
} }

INI文件的读写的更多相关文章

  1. INI 文件的读写操作

    在C#中对INI文件进行读写操作,在此要引入using System.Runtime.InteropServices; 命名空间,具体方法如下: #region 变量 private static r ...

  2. Qt对ini文件的读写

    研究了以下Qt下ini文件的读写,不废话,上干货. 写入ini文件 WriteIni.cpp void WriteIni::writeSettings() { QSettings settings(& ...

  3. 安卓读写INI文件 安卓读写INI文件

    安卓读写INI文件   安卓读写INI文件 uses System.IoUtils procedure TForm1.Button1Click(Sender: TObject);varIniFile: ...

  4. WPF操作ini 文件的读写示例

    /// <summary> /// IniFiles 的摘要说明. /// 示例文件路径:C:\file.ini /// [Server] //[*] 表示缓存区 /// name=loc ...

  5. asp.net 操作INI文件的读写,读写操作本地ini配置文件

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  6. C# 之三类文件的读写( .XML,.INI 和 .TXT 文件)

    笔记之用,关于三类.xml, .ini, .txt 文件的 C# 读写,请多多指教! 1,第一类:.xml 文件的读写 先贴上xml文件,下面对这个文件进行操作: <?xml version=& ...

  7. C#实现.ini文件读写操作

    1.ini文件是什么?        见百度百科:https://baike.baidu.com/item/ini%E6%96%87%E4%BB%B6/9718973?fr=aladdin 2.C#语 ...

  8. C#读写.ini文件

    转载来源: http://blog.csdn.net/source0573/article/details/49668079 https://www.cnblogs.com/wang726zq/arc ...

  9. C# ini文件操作【源码下载】

    介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...

随机推荐

  1. lihgtoj 1006

    记忆化搜索下即可. #include<cstdio> #include<string> #include<cstring> #include<iostream ...

  2. LittleTools之输出RenderTexture工具

    using UnityEngine; using System.Collections; using System.IO; /// <summary> /// Save render te ...

  3. UI之UItableView重用机制的性能问题

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  4. 【CSS】Intermediate5:Specificity

    1.More Specific=Greater Precedence =>nested selectors 2. the selectors are the same then the last ...

  5. ARP局域网欺骗工具编写

    每台主机都设有一个ARP高速缓存(ARP cache),里面有本局域网上各主机和路由器的IP地址和硬件地址的映射表,这些都是该主机目前知道的一些地址. 当主机A要向本局域网上的某个主机B发送IP数据报 ...

  6. cloudstack安装篇2-主机名配置

    CloudStack要求正确配置主机名.在默认情况下,安装完操作系统后,主机名是localhost.localdomain.运行下面的命令来测试: hostname --fqdn 在此处将返回这样的结 ...

  7. spring 的配置 bean>>property>>name属性

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  8. jQuery获取鼠标移动方向2

    (function($) { $.fn.extend({ show: function(div) { var w = this.width(), h = this.height(), xpos = w ...

  9. Delphi- 调用存储过程的方法

    Delphi控件里拉一个TADOStoredProc,配置好相关链系,具体的操作列子如下: procedure TForm1.btnFirstClick(Sender: TObject); begin ...

  10. maven中使用net.sf.json-lib

    <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</art ...