//============================================================ //------------------------------------------------------------ public static void CopyFileTo(this string filePath, string destFilePath, UnorderedSet <string> includedExtensions) { filePath.IsExistingFilePath().Assert(); destFilePath.IsExistingPath().Not().Assert(); if (includedExtensions.Contains(filePath.GetExtension()).Not()) { return; } filePath.CopyFileTo(destFilePath); }
public static void CopyFolderTo(this string folderPath, string destFolder, UnorderedSet <string> includedExtensions, UnorderedSet <string> excludedFolderNames) { folderPath.IsExistingFolderPath().Assert(); destFolder.IsExistingPath().Not().Assert(); if ((excludedFolderNames?.Contains(folderPath.GetFolderName())).IsTrue()) { return; } destFolder.MakeDir(); foreach (string folder in folderPath.GetChildFolderPaths()) { folder.CopyFolderTo(destFolder.CombinePath(folder.GetFolderName()), includedExtensions, excludedFolderNames); } foreach (string file in folderPath.GetChildFilePaths()) { if (includedExtensions is null || includedExtensions.Contains(file.GetExtension())) { file.CopyFileTo(destFolder.CombinePath(file.GetFileName()), includedExtensions); } } }