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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LangChain Blog
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
The Cloudflare Blog
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Martin Fowler
Martin Fowler
小众软件
小众软件
量子位
月光博客
月光博客
P
Proofpoint News Feed
IT之家
IT之家
腾讯CDC
博客园 - 三生石上(FineUI控件)
博客园 - 司徒正美
雷峰网
雷峰网
V
Visual Studio 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")]