/// <summary> /// Retrieves the value of a configuration item from its file. /// </summary> /// <param name="log">The event log to log exceptions to. May be null for no logging.</param> /// <returns>The value of the configuration item or null if not found.</returns> protected string Get(EventLog.EventLog log) { File file = null; try { // Get the file. file = new File(FilePath, false, readOnly); // Check that the file exists. if (file.Exists()) { // Return the value of the item from the file. return(file.ReadAllAsText()); } else { // The file doesn't exist. Return null. return(null); } } catch (Exception e) { // There was an error opening or reading from the file. LogException(e, log); return(null); } finally { // Close the file. if (file != null) { file.Close(); } } }
/// <summary> /// Retrieves the value of a configuration item from its file. /// </summary> /// <param name="log">The event log to log exceptions to. May be null for no logging.</param> /// <returns>The value of the configuration item or null if not found.</returns> protected string Get(EventLog.EventLog log) { File file = null; try { // Get the file. file = new File(FilePath, false, readOnly); // Check that the file exists. if (file.Exists()) { // Return the value of the item from the file. return file.ReadAllAsText(); } else { // The file doesn't exist. Return null. return null; } } catch (Exception e) { // There was an error opening or reading from the file. LogException(e, log); return null; } finally { // Close the file. if (file != null) { file.Close(); } } }