public static void ScalePicturesInFolder(string sourceFolderAbsolutePath, string targetFolderAbsolutePath, int newSize, ScaleMode mode, ImageFormat destinationFormat) { DirectoryInfo sourceDirectory = new DirectoryInfo(sourceFolderAbsolutePath); foreach (FileInfo file in FileFinderTool.FindImageFilesInFolder(sourceFolderAbsolutePath)) { string destinationFile = Path.Combine(targetFolderAbsolutePath, file.Name); if (!Directory.Exists(targetFolderAbsolutePath)) { Directory.CreateDirectory(targetFolderAbsolutePath); } ScalePictureFile(file.FullName, Path.ChangeExtension(destinationFile, destinationFormat.ToString()), newSize, mode, destinationFormat); } }
public static void FindImageFilesInFolder(string absoluteFolderPath, bool recursiveSearch, List <FileInfo> images) { DirectoryInfo directoryToLookIn = new DirectoryInfo(absoluteFolderPath); foreach (FileInfo file in directoryToLookIn.GetFiles()) { if (FileFinderTool.IsType(file, FileFinderTool.FileFormat.Image)) { images.Add(file); } } if (recursiveSearch) { foreach (DirectoryInfo directory in directoryToLookIn.GetDirectories()) { FileFinderTool.FindImageFilesInFolder(directory.FullName, true, images); } } }
public static List <FileInfo> FindImageFilesInFolder(string absoluteFolderPath) { return(FileFinderTool.FindImageFilesInFolder(absoluteFolderPath, false)); }