Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void FindImagesWithSetSize(string directoryInput, string directoryOutput, long minimumFileSize) //FileSize is in Bytes.
- {
- List<string> outputPaths = new List<string>();
- foreach (string path in Directory.GetFiles(directoryInput))
- {
- long length = new FileInfo(path).Length;
- if (length >= minimumFileSize) //Finds all valid files
- outputPaths.Add(path);
- }
- foreach (string path in outputPaths)
- {
- string outputFile = path.Replace(directoryInput, directoryOutput);
- try
- {
- File.Copy(path, outputFile); //Copies all the valid files to new directory.
- }
- catch
- {
- Console.Error.WriteLine($"{outputFile} with the same name already exists in the output directory");
- }
- }
- }
- /* Anyone is free to use this code*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement