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文件进行读取和修改的更多相关文章

  1. 轮子:读取config.ini文件

    python: 把config.ini文件成map返回 def get_conf(conf_file): conf = {} ll=list(map(lambda x: x.replace('&quo ...

  2. INI文件的读取(C语言:GetPrivateProfileString/GetPrivateProfileInt)

    INI文件格式说明 /********************************************* ini文件说明 ini文件是文本文件,由节点(Section)和键值对(key=val ...

  3. Python3 将configparser从ini文件中读取的内容转换成字典格式

    因为写脚本的用到了,所以研究了下怎么将configparser从ini文件中读取的内容转换成字典格式. 整理一下,希望能对大家有帮助. 从http://stackoverflow.com/questi ...

  4. 1. 在config.ini文件中加入dm.park.time=1,会使uap中的tomcat启动加快

    在config.ini文件中加入dm.park.time=1,会使uap中的tomcat启动加快

  5. php上传大文件时,服务器端php.ini文件中需要额外修改的选项

    几个修改点: 1.upload_max_filesize 上传的最大文件 2.post_max_size 上传的最大文件 3.max_execution_time 修改为0表示无超时,一直等待 4.m ...

  6. 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)

    Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...

  7. delphi xe4 ini文件不能读取的解决方法

    今天发现用inifiles下 tinifile.readstring方法突然不能读数据了,结果把ini文件格式由utf-8改成unicode后就能正常读取了.

  8. ASP.NET 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)

    原文:http://www.cnblogs.com/zhaopei/p/5677053.html

  9. config 数据库字符串的读取、修改 分类: WebForm 2014-12-16 10:24 203人阅读 评论(0) 收藏

    config数据库字符串: <connectionStrings>   <add name="MyWebDataString" connectionString= ...

随机推荐

  1. Case Study - 用户复购行为预测

    Problem 对于商家来说提前识别回头客是一件集中资源提高新品销售量的头等大事,各大商家为了吸引顾客的二次购买都会实行各种像是促销.优惠券.折扣之类的策略.按理说越了解客户,越知道客户的喜好,越能精 ...

  2. Qt文件发布

    1.打开Qt文件夹下的,其他版本可能为Qt (版本号)for Desktop cmd 2.将Release文件下的exe文件复制到别的文件夹,我这里为G:\Qt\QT_project\ff 3.在Qt ...

  3. Wannafly Winter Camp 2020 Day 5C Self-Adjusting Segment Tree - 区间dp,线段树

    给定 \(m\) 个询问,每个询问是一个区间 \([l,r]\),你需要通过自由地设定每个节点的 \(mid\),设计一种"自适应线段树",使得在这个线段树上跑这 \(m\) 个区 ...

  4. (node:7584) UnhandledPromiseRejectionWarning: MongooseTimeoutError: Server selection timed out after 30000 ms

    记录一次学习node.js犯的低级错误 这里遇到一个这样的问题 express连接mongoose时报错(node:7584) UnhandledPromiseRejectionWarning: Mo ...

  5. spring boot的一个小项目小型进销存系统

    项目所需的依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId&g ...

  6. Spring BeanDefinitionHolder源码解析

    BeanDefinitionHolder源码解析 继承关系 实现的接口 和BeanDefinition一样实现了BeanMetadataElement接口,获得了获取数据源(配置类的class对象)的 ...

  7. 安装Docker到Ubuntu(APT)

    运行环境 系统版本:Ubuntu 16.04.5 LTS 软件版本:Docker-CE-18.09.5 硬件配置:无 安装过程 1.卸载旧版本 root@ubuntu:~# sudo apt-get ...

  8. ArcGISServer发布流程

    发布数据服务 在进行WebGIS开发中,地图显示的内容可以分成两类:一类是底图,或者是矢量的世界地图.中国地图.某个地区的底图:另一类就是业务图,对于用于遥感数据发布的WebGIS应用就是遥感影像的边 ...

  9. Codeforces Round #624 (Div. 3) F. Moving Points 题解

    第一次写博客 ,请多指教! 翻了翻前面的题解发现都是用树状数组来做,这里更新一个 线段树+离散化的做法: 其实这道题是没有必要用线段树的,树状数组就能够解决.但是个人感觉把线段树用熟了会比树状数组更有 ...

  10. 探索drf执行流程之APIView源码分析

    Django REST framework 简介 现在新一代web应用都开始采用前后端分离的方式来进行,淘汰了以前的服务器端渲染的方式.而实现前后端分离是通过Django REST framework ...