C# 操作INI文件类 (eGlic原创)[3]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

r/>  /// 获取所有的值集合
  /// </summary>
  public ICollection Values
  {
   get {return Dictionary.Values;}
  }
  /// <summary>
  /// 添加一个可能不存在的配置项(创建一个配置项)
  /// </summary>
  /// <param name="vName">配置项名</param>
  /// <param name="vValue">配置项值</param>
  /// <returns>创建的配置项INIItem对象</returns>
  public INIItem Add(string vName,string vValue)
  {
   if(Dictionary.Contains(vName))
    return (INIItem)Dictionary[vName];
   else
   {
    INIItem o=new INIItem(this,vName,vValue);
    this.Add(o);
    return o;
   }
  }
  /// <summary>
  /// 获取指定索引的配置项
  /// </summary>
  public INIItem this[string vName]
  {
   get {
    if(Dictionary.Contains(vName))
     return (INIItem)Dictionary[vName];
    else
     return this.Add(vName,"");
   }
  }
 }
 /// <summary>
 /// INI文件操作类
 /// </summary>
 public class INIFile
 {
  #region 导入DLL函数
  [DllImport("kernel32.dll")] public extern static int GetPrivateProfileIntA(string segName,string keyName,int iDefault,string fileName);
  [DllImport("kernel32.dll")] public extern static int GetPrivateProfileStringA(string segName,string keyName,string sDefault,StringBuilder retValue,int nSize,string fileName);
  [DllImport("kernel32.dll")] public extern static int GetPrivateProfileSectionA(string segName,byte [] sData,int nSize,string fileName);
  [DllImport("kernel32.dll")] public extern static int WritePrivateProfileSectionA(string segName,byte [] sData,string fileName);
  [DllImport("kernel32.dll")] public extern static int WritePrivateProfileStringA(string segName,string keyName,string sValue,string fileName);
  [DllImport("kernel32.dll")] public extern static int GetPrivateProfileSectionNamesA(byte [] vData,int iLen,string fileName);
  #endregion

本文关键:C# 操作INI文件类 (eGlic原创)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top