社区
C#
帖子详情
C#中如何读、写INI配置文件?
alf
2003-10-24 11:00:42
如题!
...全文
155
2
打赏
收藏
C#中如何读、写INI配置文件?
如题!
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
qiuji
2003-10-24
打赏
举报
回复
C#读写INI文件:
http://www.zdnet.com.cn/developer/code/story/0,2000081534,39065664,00.htm
http://developer.ccidnet.com/pub/article/c1137_a26002_p1.html
bGene
2003-10-24
打赏
举报
回复
加载命名空间:
using System.Text;
using System.Runtime.InteropServices;
调用API
[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);
写INI文件
string FilePath = Application.StartupPath + "Test.ini";
string Section = "Section"; //段落名
string Key = "Key"; //节点名
string KeyValue = "KeyValue"; //节点值
long temp = WritePrivateProfileString(Section,Key,KeyValue,FilePath);
if(temp>0)
MessageBox.Show("成功写入INI文件!","信息");
读INI文件
StringBuilder Temp = new StringBuilder(255);
string FilePath = Application.StartupPath + "Test.ini";
string Section = "Section"; //段落名
string Key = "Key"; //节点名
int i = GetPrivateProfileString ( Section,Key,"无法读取对应数值!",Temp,255,FilePath);
//显示读取的数值
MessageBox.Show(Temp.ToString());
C#
读
写
ini
配置文件
的方法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Runtime.InteropServices; /// <summary> ///
ini
文件的
读
取和
写
入 /// </summary> class Operate
Ini
File { #re..
C#
对
INI
配置文件
进行
读
写
操作方法
【代码】
C#
对
INI
配置文件
进行
读
写
操作方法。
C#
读
写
ini
文件
关于
C#
如何
读
写
ini
文件 什么是
ini
文件,
ini
文件的组成结构如下: 即由section(图
中
Gain Info)节点名称,KEY(图
中
G1 Gain)和Value(等号后的数值组成)。一般作为程序的
配置文件
。
C#
通过调用两个系统API函数就可以进行对
ini
文件的
读
写
。 首先要引用using System.Runtime.InteropServices; [DllImport(“ker...
读
取设置config.
ini
配置
class CSense
Ini
{ /************************************************************************/ /*
写
操作 * strSection 节 * strKey 键 * strValue ...
C#
读
写
配置文件
C#
读
写
配置文件
using System;using System.Runtime.InteropServices; using System.Text;namespace Mp3Manager.Comm{ /// /// RW
Ini
的摘要说明。 /// public class RW
Ini
{ [DllImport("kernel32")] private static exte
C#
111,128
社区成员
642,534
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章