jeudi 5 novembre 2020

file.copy multiple files c#

I'm looking to see if there is a more efficient way of copying certain files from a folder to another folder. There are a lot of files so i'm wondering if there's an easier way. Thank you.

Example:

file1.jpg
file1.bmp
file1.gif

file2.jpg
file2.bmp
file2.bmp

if (chkbox1.Checked)
{
   File.Copy(sourcedir + "\\file1.jpg", targetdir + "\\file1.jpg", true); 
   File.Copy(sourcedir + "\\file1.bmp", targetdir + "\\file1.bmp", true);   
   File.Copy(sourcedir + "\\file1.gif", targetdir + "\\file1.gif", true);   
}

if (chkbox2.Checked)
{
   File.Copy(sourcedir + "\\file2.jpg", targetdir + "\\file2.jpg", true); 
   File.Copy(sourcedir + "\\file2.bmp", targetdir + "\\file2.bmp", true);   
   File.Copy(sourcedir + "\\file2.gif", targetdir + "\\file2.gif", true);   
}



Aucun commentaire:

Enregistrer un commentaire