惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
Vercel News
Vercel News
U
Unit 42
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog RSS Feed
N
Netflix TechBlog - Medium
GbyAI
GbyAI
F
Fortinet All Blogs
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
M
MIT News - Artificial intelligence
D
Docker
IT之家
IT之家
Stack Overflow Blog
Stack Overflow Blog

博客园 - 点点小铺

招聘Delphi程序员,懂.Net----广州地区(08年4月1日前有效) 用C# 实现C/S模式下软件自动在线升级 判断一个字符串是否全是数字的多种方法及其性能比较(C#实现)--来源CSDN 使用ADOX创建Access数据库和表-- 来源于CSDN 运用C#制作屏幕捕捉程序(2) 运用C#制作屏幕捕捉程序(1) 通过WMI获得硬盘和CPU的物理序列号 探讨C#中字符串的加密 在 C# 中加载自己编写的动态链接库 用C#生成随机中文汉字验证码的基本原理 c#中结构与类的区别 C#中对注册表的操作 C#中调用Windows API的要点 C#的多线程机制初探(4) C#的多线程机制初探(3) C#的多线程机制初探(2) C#的多线程机制初探(1) C#中如何插入照片到Excel C#编程让Outlook乖乖交出帐户密码
C#中如何读写INI文件
点点小铺 · 2006-10-07 · via 博客园 - 点点小铺

C#中读取和写入ini文件的一段代码,其实本文只是指出一个方向,希望大家能够触类旁通。

  以下为代码全文:

  //INI文件
  [ DllImport ( "kernel32" ) ]
  private static extern bool WritePrivateProfileString ( string section ,string key , string val , string filePath ) ;
  //ini文件(字符
  [ DllImport ( "kernel32" ) ]
  private static extern int GetPrivateProfileString ( string section ,string key , string def , StringBuilder retVal ,int size , string filePath ) ;

  //ini文件(数字
  [ DllImport ( "kernel32" ) ]
  private static extern int GetPrivateProfileInt ( string section ,string key , int def , string filePath ) ;

  //////////////////////////////////////////////////////////////
  using System;
  using System.IO;
  using System.Runtime.InteropServices;
  using System.Text;

  namespace EchonComponentLibrary
  {
  /// <summary>
  /// IniFile 的摘要说明。
  /// </summary>
  public class IniFile
  {
  private string FFileName;

  [DllImport("kernel32")]