示例#1
0
 public override void SetValue(string section, string entry, object value)
 {
     if (section == null || entry == null)
     {
         return;
     }
     if (value == null)
     {
         this.RemoveEntry(section, entry);
     }
     else
     {
         this.VerifyNotReadOnly();
         this.VerifyName();
         this.VerifyAndAdjustSection(ref section);
         this.VerifyAndAdjustEntry(ref entry);
         if (!this.RaiseChangeEvent(true, ProfileChangeType.SetValue, section, entry, value))
         {
             return;
         }
         if (Ini.WritePrivateProfileString(section, entry, value.ToString(), this.Name) == 0)
         {
             throw new Win32Exception();
         }
         this.RaiseChangeEvent(false, ProfileChangeType.SetValue, section, entry, value);
     }
 }
示例#2
0
 public override void RemoveSection(string section)
 {
     if (!this.HasSection(section))
     {
         return;
     }
     this.VerifyNotReadOnly();
     this.VerifyName();
     this.VerifyAndAdjustSection(ref section);
     if (!this.RaiseChangeEvent(true, ProfileChangeType.RemoveSection, section, (string)null, (object)null))
     {
         return;
     }
     if (Ini.WritePrivateProfileString(section, 0, "", this.Name) == 0)
     {
         throw new Win32Exception();
     }
     this.RaiseChangeEvent(false, ProfileChangeType.RemoveSection, section, (string)null, (object)null);
 }