教你在C#中如何读写INI文件
2024-07-21 02:19:17
供稿:网友
 
在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")]