Select all images in the folder and save them in other folder

1.5k Views Asked by At

I have a folder on my local machine that contains .jpeg files. I want to select all of these images and save them in the other folder. That is all. I am using c# and ASP.NET Webforms. Is there an easy way of doing so?

Thank you.

1

There are 1 best solutions below

0
On BEST ANSWER

Something like this should do the trick:

var filesToCopy = Directory.EnumerateFiles(@"c:\path to images", "*.jpeg");

var directoryToCopyTo = "c:\destination folder";

foreach (var file in filesToCopy)
{
    File.Copy(file, Path.Combine(directoryToCopyTo, Path.GetFileName(file)));
}

Note: This won't copy images in sub-folders