/// <summary> /// Called just before the thread finishes, regardless of status, to take any /// necessary action on the downloaded file. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="finalStatus"> /// The final Status. /// </param> private static void CleanupDestination(State state, DownloadStatus finalStatus) { CloseDestination(state); if (state.Filename != null && finalStatus.IsError() && File.Exists(state.Filename)) { File.Delete(state.Filename); state.Filename = null; } }
/// <summary> /// Called just before the thread finishes, regardless of status, to take any /// necessary action on the downloaded file. /// </summary> /// <param name="state"> /// The state. /// </param> /// <param name="finalStatus"> /// The final Status. /// </param> private static void CleanupDestination(State state, DownloadStatus finalStatus) { CloseDestination(state); if (state.Filename != null && finalStatus.IsError() && File.Exists(state.Filename)) { File.Delete(state.Filename); state.Filename = null; } }
/// <summary> /// Returns whether the download has completed (either with success or /// error). /// </summary> /// <param name="status"> /// The status. /// </param> /// <returns> /// The is status completed. /// </returns> public static bool IsCompleted(this DownloadStatus status) { return(status.IsSuccess() || status.IsError()); }