private static void Copy(CopyOptions copyOptions) { if (false == File.Exists(copyOptions.SourceFilename)) { throw new FileNotFoundException("Copy source was not found", copyOptions.SourceFilename); } var localCopy = new LocalCopy(); var stopwatch = new Stopwatch(); if (copyOptions.MeasureTime) { stopwatch.Start(); } if (copyOptions.Resumable) { CopyResumableFile(localCopy, copyOptions); } else { CopyFile(localCopy, copyOptions); } if (copyOptions.MeasureTime) { stopwatch.Stop(); Console.WriteLine(string.Format("Copy took {0} minutes ({1} seconds)", stopwatch.Elapsed.TotalMinutes, stopwatch.Elapsed.TotalSeconds)); } }
private static void CopyResumableFile(LocalCopy localCopy, CopyOptions copyOptions) { FileMode fileMode = FileMode.OpenOrCreate; if (copyOptions.Overwrite) { fileMode = FileMode.Create; } if (copyOptions.Threaded) { localCopy.ThreadedCopyResumableFile(copyOptions.SourceFilename, copyOptions.TargetFilename, fileMode, copyOptions.BufferCount, copyOptions.BufferSize); } else { localCopy.CopyResumableFile(copyOptions.SourceFilename, copyOptions.TargetFilename, fileMode, copyOptions.BufferSize); } }