博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ini文件操作
阅读量:4630 次
发布时间:2019-06-09

本文共 1642 字,大约阅读时间需要 5 分钟。

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(255);            // section=配置节,key=键名,temp=上面,path=路径            GetPrivateProfileString(section, key, "", temp, 255, 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);*/

 

转载于:https://www.cnblogs.com/elves/p/3610558.html

你可能感兴趣的文章
关于DWG文件转换成PDF
查看>>
Jerry眼中的SAP客户数据模型
查看>>
c++, 派生类的构造函数和析构函数 , [ 以及operator=不能被继承 or Not的探讨]
查看>>
CAS (10) —— JBoss EAP 6.4下部署CAS时出现错误exception.message=Error decoding flow execution的解决办法...
查看>>
[面试]future模式
查看>>
Beta冲刺 (1/7)
查看>>
cap理论与分布式事务的解决方案
查看>>
[PHP] JQuery+Layer实现添加删除自定义标签代码
查看>>
Linux下查看和添加环境变量
查看>>
Ubuntu18.04安装英伟达显卡驱动
查看>>
Winform开发中常见界面的DevExpress处理操作
查看>>
IOS_多线程_ASI_AFN_UIWebView
查看>>
主要的约瑟夫环问题
查看>>
自定义View步骤学习笔记
查看>>
ab压力测试
查看>>
第11章 AOF持久化
查看>>
2009年3月
查看>>
03 Django REST Framework 视图和路由
查看>>
Confluence 6 配置服务器基础地址
查看>>
Android通过ksoap2调用.net(c#)的webservice
查看>>