ini文件操作
Config.ini 文件操作
[SYS]
sysname=hy
company=hyhy
tel=2
using System;
using System.Collections.Generic;
using System.Text; namespace Common
{
public class SetINI
{
// 声明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;
public SetINI(string path)
{
this.sPath = path;
} public void Writue(string section, string key, string value)
{
// section=配置节,key=键名,value=键值,path=路径
WritePrivateProfileString(section, key, value, sPath);
}
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();
}
}
}
/*
string sCompany = "";
string Current = Directory.GetCurrentDirectory();//获取当前根目录 SetINI ini = new SetINI(Current + "/config.ini");
sCompany = ini.ReadValue("SYS", "company");
*/
//写入
/*
ini .Writue("SYS", "company", companyValue);
*/
ini文件操作的更多相关文章
- ini 文件操作记要(1): 使用 TIniFile
ini 文件操作记要(1): 使用 TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Class ...
- winform INI文件操作辅助类
using System;using System.Runtime.InteropServices;using System.Text; namespace connectCMCC.Utils{ // ...
- Ini文件操作类
/// <summary> /// Ini文件操作类 /// </summary> public class Ini { // 声明INI文件的写操作函数 WritePriva ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- C#读写ini文件操作
ini文件,是windows操作系统下的配置文件,ini文件是一种按照特点方式排列的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = val ...
- C# Ini文件操作
在开源中国看到的操作ini文件的,写的还不看,留着以后用 using System; using System.IO; using System.Runtime.InteropServices; us ...
- 读写INI文件操作类
详情介绍:http://zh.wikipedia.org/wiki/INI%E6%96%87%E4%BB%B6 示例: 下面是一个虚拟的程序,其INI文件有两个小节,前面的小节是用来设置拥有者的信息, ...
- python基础——15(加密、excel操作、ini文件操作、xml操作模块及数据格式分类)
一.加密模块 1.有解密的加密方式(base64) #base64加密 import base64 str_encrypt = input("输入要加密的字符串:\n") base ...
- Delphi ini文件操作 TIniFile、TMemIniFile
1.使用TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...
随机推荐
- runtime笔记一
一.iOS中_cmd The _cmd variable is a hidden argument passed to every method that is the current selecto ...
- 将maven工程转成dynamic web project
http://blog.csdn.net/remote_roamer/article/details/51724378 做到最后一步就不行鸟,没有plugin........
- Linq------各种查询语句大全
查询Title列的第一个值 string str = db.Webs.Select(p => p.Title).FirstOrDefault(); 根据ID,查询Title列的第一个值 b.We ...
- WinForm------GridControl显示每行的Indicator中的行号
1.修改Indicator的行宽 2.添加CustomDrawRowIndicator事件 private void AdminCardView_CustomDrawRowIndicator(obje ...
- 基本药目录sop
http://db.yaozh.com/basicdir 基本药物 编辑 "基本药物"的概念, 由世界卫生组织于1977年提出,指的是能够满足基本医疗卫生需求,剂型适宜.保证供应. ...
- 如何让Chrome浏览器可以加载本地XML文件?
Chrome浏览器的安全限制,禁止本地加载XML等外部文件,如何设置让其可以加载呢? 有两种方法,第一种是在本地服务器环境下浏览,采用 http://localhost/ 的方式浏览你的网页和文件,就 ...
- vs2013 支持C#6.0 Install-Package Microsoft.Net.Compilers
vs2013 支持C#6.0 Install-Package Microsoft.Net.Compilers
- jsp简单标签开发(一)
孤傲苍狼 @Override22 public void doTag() throws JspException, IOException {23 //得到代表jsp标签体的JspFragment24 ...
- wampserver 2.5安装pear win8.1
集成环境的悲伤啊~ 本来看到pear想试试 结果发现根本没有go-pear.bat 自己的环境 都是 系统win 8.1 php 5.5.12 mysql 5.6.17 apache 2.4.9 ...
- svn 回滚到某个版本
用svn merge命令来进行回滚. 回滚的操作过程如下: 1.保证我们拿到的是最新代码: svn update 假设最新版本号是28. 2.然后找出要回滚的确切版本号: svn log 假设根据sv ...