Exemple #1
0
        /// <summary>
        ///     Deletes the specified file.
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="suppressErrors"></param>
        private void DeleteFile(string filePath, bool suppressErrors)
        {
            var retryCount = 0;

            while (retryCount < MaxRetryCount)
            {
                try
                {
                    if (!File.Exists(filePath))
                    {
                        return;
                    }

                    File.Delete(filePath);

                    _eventLog.WriteTrace("Deleted file {0} from repository {1}.", filePath, Name);

                    break;
                }
                catch (Exception exception)
                {
                    retryCount++;

                    if (retryCount >= MaxRetryCount)
                    {
                        if (suppressErrors)
                        {
                            _eventLog.WriteTrace("An error occured deleting file {0} from file repository at {1}. Error {2}.", filePath, Name, exception);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 ///     Writes the trace.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="args">The arguments.</param>
 public void WriteTrace(string message, params object[] args)
 {
     _view.WriteTrace(message, args);
 }