public string GetSetting(string section, string name) { string filePath = GetSettingFilename(section); string setting = _ini.GetSetting(section, name, filePath); if (String.IsNullOrEmpty(setting) || String.IsNullOrEmpty(_config.EncryptionPassword)) { return(setting); } return(_crypt.Decrypt(setting, _config.EncryptionPassword)); }
/// <summary> /// Managed version of GetPrivateProfileString<br/> /// No COM Interop is used<br/> /// If the file does not exist or the value is not in the file, the defaultValue is used.<br/> /// See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724348%28v=vs.85%29.aspx /// </summary> /// <param name="sectionName">The INI Section Name. Use GLOBAL for the global section.</param> /// <param name="settingName">The INI Setting Name</param> /// <param name="defaultValue">The default value if there is no value</param> /// <param name="returnedString">Output of the string</param> /// <param name="size">The number of buffer characters (not used but here for backward compatibility)</param> /// <param name="filePath">The path to the INI file</param> /// <returns>Number of characters returned</returns> /// <exception caption="" cref="ArgumentNullException">Occurs when sectionName, settingName or filePath is null</exception> public static int GetPrivateProfileString(string sectionName, string settingName, string defaultValue, out string returnedString, int size, string filePath) { IniReaderWriter iniReaderWriter = new IniReaderWriter(); returnedString = iniReaderWriter.GetSetting(sectionName, settingName, filePath) ?? defaultValue; if (returnedString == null) { return(0); } return(returnedString.Length); }
/// <summary> /// Managed version of GetPrivateProfileString<br/> /// No COM Interop is used<br/> /// If the file does not exist or the value is not in the file, the defaultValue is used.<br/> /// See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724348%28v=vs.85%29.aspx /// </summary> /// <param name="sectionName">The INI Section Name. Use GLOBAL for the global section.</param> /// <param name="settingName">The INI Setting Name</param> /// <param name="defaultValue">The default value if there is no value</param> /// <param name="returnedBuffer">StrinbBuilder Output of the string</param> /// <param name="size">The number of buffer characters (not used but here for backward compatibility)</param> /// <param name="filePath">The path to the INI file</param> /// <returns>Number of characters returned</returns> /// <exception cref="ArgumentNullException">Occurs when sectionName, settingName or filePath is null</exception> public static int GetPrivateProfileString(string sectionName, string settingName, string defaultValue, StringBuilder returnedBuffer, int size, string filePath) { IniReaderWriter iniReaderWriter = new IniReaderWriter(); string result = iniReaderWriter.GetSetting(sectionName, settingName, filePath) ?? defaultValue; if (result == null) { return(0); } returnedBuffer.Append(result); return(result.Length); }
/// <summary> /// Managed version of GetPrivateProfileInt<br/> /// No COM Interop is used<br/> /// If the file does not exist or the value is not in the file, the defaultValue is used.<br/> /// See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724348%28v=vs.85%29.aspx /// </summary> /// <param name="sectionName">The INI Section Name. Use GLOBAL for the global section.</param> /// <param name="settingName">The INI Setting Name</param> /// <param name="defaultValue">The default value if there is no value</param> /// <param name="filePath">The path to the INI file</param> /// <returns>The integer</returns> /// <exception caption="" cref="ArgumentNullException">Occurs when sectionName, settingName or filePath is null</exception> public static int GetPrivateProfileInt(string sectionName, string settingName, int defaultValue, string filePath) { int result = defaultValue; IniReaderWriter iniReaderWriter = new IniReaderWriter(); string value = iniReaderWriter.GetSetting(sectionName, settingName, filePath); if (String.IsNullOrEmpty(value)) { return(result); } Int32.TryParse(value, out result); return(result); }