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 ...
随机推荐
- iOS - 沙盒中,如何判断存在文件、目录
在iOS开发中,在沙盒中创建沙盒一些存储各个功能的文件目录或者文件. 使用: [NSFileManager defaultManager] 1.判断目录,用她可以. 2.判断文件,用她可以. 3.创建 ...
- NOIp 0910 爆零记
这套题是神犇chty出的. 刚拿到题的时候有点懵逼,因为按照一般的套路第一题都是一眼题,但是看到第一题后想了很多个算法和数据结构好像都不能很好的解决.然后就随手敲了个暴力去看T2. 嗯...文件名是b ...
- hibernate实现有两种配置,xml配置与注释配置。
(1):xml配置:hibernate.cfg.xml (放到src目录下)和实体配置类:xxx.hbm.xml(与实体为同一目录中) <?xml version='1.0' encoding= ...
- select例子
好长时间没有写了,其实一直在坚持学习. #include <sys/types.h> #include <sys/socket.h> #include <stdio.h& ...
- sudo 出现unable to resolve host 解决方法
inux 环境, 假设这台机器名字叫dev(机器的hostname), 每次执行sudo 就出现这个警告讯息:sudo: unable to resolve host dev虽然sudo 还是可以正常 ...
- 第一章 基础设施,1.3 阿里视频云ApsaraVideo是怎样让4000万人同时狂欢的(作者:蔡华)
1.3 阿里视频云ApsaraVideo是怎样让4000万人同时狂欢的 前言 在今年的双11中,双11天猫狂欢夜的直播成为一大亮点. 根据官方披露数据,直播总观看人数超4257万,同时观看人数峰值达5 ...
- Oracle数据库管理系统下对数据库操作常用命令
desc表名; /*查看表结构*/ alter table ...
- docker快速搭建wordpress(centos7)
docker pull tutum/wordpress #拉取镜像 docker run -d -p 80:80 tutum/wordpress #运行容器 使用服务器IP访问即可
- json_encode
html文件 <html> <title>php+jquery+ajax+json简单小例子</title> <?php header("Conte ...
- PHP file_get_contents设置超时处理方法
从PHP5开始,file_get_content已经支持context了(手册上写着:5.0.0 Added the context support. ),也就是说,从5.0开始,file_get_c ...