Tp.Integration.Plugin.Common.Activity.PluginRollingFileAppender.DeleteFile C# (CSharp) Method

DeleteFile() protected method

protected DeleteFile ( string fileName ) : void
fileName string
return void
		protected void DeleteFile(string fileName)
		{
			using (SecurityContext.Impersonate(this))
			{
				if (!FileExists(fileName))
				{
					return;
				}
			}

			string path = fileName;
			string destFileName = string.Concat(new object[] {fileName, ".", Environment.TickCount, ".DeletePending"});
			try
			{
				using (SecurityContext.Impersonate(this))
				{
					System.IO.File.Move(fileName, destFileName);
				}

				path = destFileName;
			}
			catch (Exception ex)
			{
				LogLog.Debug(
					"RollingFileAppender: Exception while moving file to be deleted [" + fileName + "] -> [" + destFileName + "]", ex);
			}
			try
			{
				using (SecurityContext.Impersonate(this))
				{
					System.IO.File.Delete(path);
				}

				LogLog.Debug("RollingFileAppender: Deleted file [" + fileName + "]");
			}
			catch (Exception ex)
			{
				if (path == fileName)
				{
					ErrorHandler.Error("Exception while deleting file [" + path + "]", ex, ErrorCode.GenericFailure);
				}
				else
				{
					LogLog.Debug("RollingFileAppender: Exception while deleting temp file [" + path + "]", ex);
				}
			}
		}