public async Task CopyAsync(string sourceFilePath, string targetFilePath, CancellationToken cancellationToken) { using (_Logger.LogScope(LogLevel.Verbose, $"Copying '{sourceFilePath}' to '{targetFilePath}'")) { await _FileContentsCopier.CopyFileContentsAsync(sourceFilePath, targetFilePath, this, cancellationToken); File.SetAttributes(targetFilePath, File.GetAttributes(sourceFilePath)); File.SetCreationTimeUtc(targetFilePath, File.GetCreationTimeUtc(sourceFilePath)); File.SetLastWriteTimeUtc(targetFilePath, File.GetLastWriteTimeUtc(sourceFilePath)); File.SetLastAccessTimeUtc(targetFilePath, File.GetLastAccessTimeUtc(sourceFilePath)); } }
private async Task SlowMove([NotNull] string sourceFilePath, [NotNull] string targetFilePath, CancellationToken cancellationToken) { using (_Logger.LogScope(LogLevel.Verbose, $"Moving '{sourceFilePath}' to '{targetFilePath}'")) { try { await _FileContentsCopier.CopyFileContentsAsync(sourceFilePath, targetFilePath, this, cancellationToken); cancellationToken.ThrowIfCancellationRequested(); File.Delete(sourceFilePath); } catch (Exception ex) { _Logger.LogException(ex); if (File.Exists(targetFilePath)) { File.Delete(targetFilePath); } throw; } } }