public override byte[] ReadBinary(string sectionName, string keyName) { if (this.fileName == "") { return(null); } byte[] result; try { StringBuilder stringBuilder = new StringBuilder(1024); SettingIniFile.GetPrivateProfileString(sectionName, keyName, "", stringBuilder, (uint)stringBuilder.Capacity, this.fileName); string text = Tools.AnyToString(stringBuilder.ToString()); if (text == string.Empty) { result = null; } else { byte[] array = Convert.FromBase64String(text); result = array; } } catch (Exception) { result = null; } return(result); }
public override string ReadString(string sectionName, string keyName) { if (this.fileName == "") { return(""); } string result; try { StringBuilder stringBuilder = new StringBuilder(1024); SettingIniFile.GetPrivateProfileString(sectionName, keyName, "", stringBuilder, (uint)stringBuilder.Capacity, this.fileName); string text = Tools.AnyToString(stringBuilder.ToString()); if (text == string.Empty) { result = ""; } else if (this.encryptionSetting) { result = Crypt.Decrypt(text); } else { result = text; } } catch (Exception) { result = ""; } return(result); }
public override bool WriteString(string sectionName, string keyName, string value) { if (this.fileName == "") { return(false); } bool result; try { string lpEntryString; if (this.encryptionSetting) { lpEntryString = Crypt.Encrypt(value, this.encryptionKey); } else { lpEntryString = value; } SettingIniFile.WritePrivateProfileString(sectionName, keyName, lpEntryString, this.fileName); result = true; } catch (Exception) { result = false; } return(result); }
public override bool WriteBinary(string sectionName, string keyName, byte[] value) { if (this.fileName == "") { return(false); } if (value == null) { return(false); } bool result; try { string lpEntryString = Convert.ToBase64String(value); SettingIniFile.WritePrivateProfileString(sectionName, keyName, lpEntryString, this.fileName); result = true; } catch (Exception) { result = false; } return(result); }