C#对config.ini文件进行读取和修改
C#对config.ini文件进行读取和修改:
public partial class Patrolcar : Form之后可以加入如下类:
#region
public class IniFile
{
public string map_length, map_width, maxnum_connect, net_ip;
public string path;
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal,
int size, string filePath); public IniFile(string INIPath)
{
path = INIPath;
} public void getIni()
{
map_length = IniReadValue("setting", "map_length").ToString();
map_width = IniReadValue("setting", "map_width").ToString();
maxnum_connect = IniReadValue("setting", "maxnum_connect").ToString();
net_ip = IniReadValue("setting", "net_ip").ToString();
} public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
} public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder();
int i = GetPrivateProfileString(Section, Key, "", temp, , this.path);
return temp.ToString();
}
} IniFile dgd_ini = new IniFile(System.IO.Path.Combine(Application.StartupPath, "config.ini"));
#endregion
然后在InitializeComponent();语句之后就可以进行函数操作了:
InitializeComponent();
dgd_ini.getIni();
config.ini文件位于...\bin\Debug目录下。
C#对config.ini文件进行读取和修改的更多相关文章
- 轮子:读取config.ini文件
python: 把config.ini文件成map返回 def get_conf(conf_file): conf = {} ll=list(map(lambda x: x.replace('&quo ...
- INI文件的读取(C语言:GetPrivateProfileString/GetPrivateProfileInt)
INI文件格式说明 /********************************************* ini文件说明 ini文件是文本文件,由节点(Section)和键值对(key=val ...
- Python3 将configparser从ini文件中读取的内容转换成字典格式
因为写脚本的用到了,所以研究了下怎么将configparser从ini文件中读取的内容转换成字典格式. 整理一下,希望能对大家有帮助. 从http://stackoverflow.com/questi ...
- 1. 在config.ini文件中加入dm.park.time=1,会使uap中的tomcat启动加快
在config.ini文件中加入dm.park.time=1,会使uap中的tomcat启动加快
- php上传大文件时,服务器端php.ini文件中需要额外修改的选项
几个修改点: 1.upload_max_filesize 上传的最大文件 2.post_max_size 上传的最大文件 3.max_execution_time 修改为0表示无超时,一直等待 4.m ...
- 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)
Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...
- delphi xe4 ini文件不能读取的解决方法
今天发现用inifiles下 tinifile.readstring方法突然不能读数据了,结果把ini文件格式由utf-8改成unicode后就能正常读取了.
- ASP.NET 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)
原文:http://www.cnblogs.com/zhaopei/p/5677053.html
- config 数据库字符串的读取、修改 分类: WebForm 2014-12-16 10:24 203人阅读 评论(0) 收藏
config数据库字符串: <connectionStrings> <add name="MyWebDataString" connectionString= ...
随机推荐
- 【编译原理】TEST递归下降演示
MyUtil.java package Util; import Value_Final.RRule; public class MyUtil { /** * 判断字符串是否是关键字 * @param ...
- [大数据技术]Kettle初次连接MySQL数据库 报错问题 错误连接数据库 Error occured while trying to connect to the database Exception while loading class org.gjt.mm.mysql.Driver
报错内容如下: 错误连接数据库 [foodmartconn] : org.pentaho.di.core.exception.KettleDatabaseException: Error occure ...
- ex03
1. a heuristic function h(n): a heuristic value of n, that is the estimated cost of reaching goal fr ...
- java【第三课 条件语句】
一.java条件语句 import java.util.Scanner; //导入扫描仪 public class demo{ public static void main(String[] arg ...
- P5163 WD与地图 [整体二分,强连通分量,线段树合并]
首先不用说,倒着操作.整体二分来做强连通分量,然后线段树合并,这题就做完了. // powered by c++11 // by Isaunoya #include <bits/stdc++.h ...
- 关于Hosts与network的异同之处
1.hosts文件,路径:/etc/hosts,此文间是在网络上使用的,用于解析计算机名称和IP地址的映射关系,功能相当于windows下面的c:\windows\system32\drivers\e ...
- 树莓派查看ip地址(命令ifconfig)和退出ping
1.1树莓派查看ip地址用如下命令: ifconfig -a 结果如下图所示: 注意:树莓派查看ip地址是用命令ifconfig,而Windows的cmd命令查看ip地址是ipconfig.
- php 字符串常用函数
数组.字符串和数据库是我们函数里面最.最.最常用的三类函数. 当然PHP的字符串函数也有很多.我们最常使用的两个系列的字符串: 1.单字节字符串处理函数 2.多字节字符串处理函数 3.字符串编码转换函 ...
- mysql 数据库优化的几种方法
1.选取最适用的字段属性 MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快.因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽 ...
- LeetCode subarray-sum-equals-k题解 前缀和+Hash表+枚举——线性做法
文章目录 题意 思路 连续子数组的和sum[i,j] 源码 结果记录 题意 给定一个数组,求连续的子数组的和为k的子数组个数. 思路 连续子数组的和sum[i,j] sum[i,j]=∑k=ijAk( ...