在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")]
新聞熱點
疑難解答