private static void CopyAllFilesAsync(string originalOutputPath, string standardOutputPath) { if (Directory.Exists(standardOutputPath)) { Directory.Delete(standardOutputPath, true); } void action(string sourceFile) { string destinationFile = $"{standardOutputPath}/{sourceFile.Remove(0, originalOutputPath.Length)}"; BuildManagerUtility.EnsureDirectoryExists(Path.GetDirectoryName(destinationFile)); File.Copy(sourceFile, destinationFile); } string[] files = Directory.GetFiles(originalOutputPath, "*", SearchOption.AllDirectories); Parallel.ForEach(files, action); }
private static void CopyAllFilesAsync(string originalOutputPath, string standardOutputFolderPath, string buildName) { if (Directory.Exists(standardOutputFolderPath)) { Directory.Delete(standardOutputFolderPath, true); } string originalOutputFolderPath = Path.GetDirectoryName(originalOutputPath); string originalOutputFileName = Path.GetFileNameWithoutExtension(originalOutputPath); Assert.IsFalse(string.IsNullOrWhiteSpace(originalOutputFolderPath)); string ignoredFolder = Path.Combine(originalOutputFolderPath, $"{originalOutputFileName}{IgnoredFolderSuffix}"); void action(string sourceFile) { if (sourceFile.StartsWith(ignoredFolder)) { return; } string relativePath = sourceFile.Remove(0, originalOutputFolderPath.Length + 1); string standardOutputFileName; if (relativePath.StartsWith(originalOutputFileName)) { standardOutputFileName = $"{buildName}{relativePath.Remove(0, originalOutputFileName.Length)}"; } else { standardOutputFileName = relativePath; } string destinationFile = $"{standardOutputFolderPath}/{standardOutputFileName}"; BuildManagerUtility.EnsureDirectoryExists(Path.GetDirectoryName(destinationFile)); File.Copy(sourceFile, destinationFile); } string[] files = Directory.GetFiles(originalOutputFolderPath, "*", SearchOption.AllDirectories); Parallel.ForEach(files, action); }