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= ...
随机推荐
- 纪中18日c组模拟赛
T2 GMOJ2127. 电子表格 (File IO): input:excel.in output:excel.out 时间限制: 1000 ms 空间限制: 262144 KB 具体限制 ...
- C语言 杂货整理
C语言 杂货整理 #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include ...
- React函数式组件使用Ref
目录: 简介 useRef forwardRef useImperativeHandle 回调Ref 简介 大家都知道React中的ref属性可以帮助我们获取子组件的实例或者Dom对象,进而对子组件进 ...
- selenium规避网站监测
规避网站监测 现在不少大网站有对selenium采取了监测机制.比如正常情况下我们用浏览器访问淘宝等网站的window.navigator.webdriver的值为undefined.而使用sel ...
- LeetCode:26删除有序数组中相同的数.(Python3)
给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度. 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成. 示例 1 ...
- LeetCode-21 有序链表的合并
问题描述: 将两个有序链表合并为一个新的有序链表并返回.新链表是通过拼接给定的两个链表的所有节点组成的. 示例: 输入:1->2->4, 1->3->4输出:1->1-& ...
- P4802 [CCO 2015]路短最
Problem 这题的题意是 求一条 经过 起点和终点的 最长路径.且一个点只能经过一次. 我们设定 \(dis_{i,j}\) 为 i 到 j 的距离(应该没有重边) 要注意的是 不能用 \(Flo ...
- 新建Microsoft Word文档
问题描述 L正在出题,新建了一个word文档,想不好取什么名字,身旁一人惊问:“你出的题目叫<新建Microsoft Word文档>吗?”,L大喜,一拍桌子,说:“好,就叫这个名字了.” ...
- ASP.NET Identity登录原理
https://www.cnblogs.com/jesse2013/p/aspnet-identity-claims-based-authentication-and-owin.html 如何实现登录 ...
- Web_0003:关于PHP上传文件大小的限制
相关设置如下: 1,file_uploads = on 是否允许通过HTTP上传文件的开关,默认为ON即是开 2,upload_max_filesize = 8m ; 即允许上传文件大小的最大值.默 ...