コード例 #1
0
        /// <summary>
        /// Writes a configuration item's value to a file.
        /// </summary>
        /// <param name="value">The value to write to the file.</param>
        /// <param name="log">The event log to log exceptions to. May be null for no logging.</param>
        /// <returns>True if the write was successful, false otherwise.</returns>
        protected bool Write(string value, EventLog.EventLog log)
        {
            // Write the value to the file.
            File file = null;

            try
            {
                file = new File(FilePath, false);
                return(file.WriteLine(value));
            }
            catch (Exception e)
            {
                // There was an error opening the file.
                LogException(e, log);
                return(false);
            }
            finally
            {
                // Close the file.
                if (file != null)
                {
                    file.Close();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Writes a configuration item's value to a file.
 /// </summary>
 /// <param name="value">The value to write to the file.</param>
 /// <param name="log">The event log to log exceptions to. May be null for no logging.</param>
 /// <returns>True if the write was successful, false otherwise.</returns>
 protected bool Write(string value, EventLog.EventLog log)
 {
     // Write the value to the file.
     File file = null;
     try
     {
         file = new File(FilePath, false);
         return file.WriteLine(value);
     }
     catch (Exception e)
     {
         // There was an error opening the file.
         LogException(e, log);
         return false;
     }
     finally
     {
         // Close the file.
         if (file != null)
         {
             file.Close();
         }
     }
 }