using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ForMailRu { public partial class Form1 : Form { string folder; public Form1() { InitializeComponent(); label1.Text = ""; label2.Text = ""; } async void MovesImages() { await Task.Run(() => { if (label1.Text != "" && label2.Text != "") { //получаем файлы первой папки string[] massFile = SearchFilesP(label1.Text); //Путь до второй папки string folderath2 = label2.Text; folderath2 += "\\"; //Осталась лишь механика переноса либо копирования файлов foreach (string filename in massFile) { System.IO.File.Copy(filename, folderath2 + System.IO.Path.GetFileName(filename)); //Перемещение //System.IO.File.Move(filename, folderath2 + System.IO.Path.GetFileName(filename)); } MessageBox.Show("Succes!", "Ok!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }); } private void button1_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { folder = folderBrowserDialog1.SelectedPath; label1.Text = folder; } } string[] SearchFilesP(string Path) { return System.IO.Directory.EnumerateFiles(Path, "*.*", System.IO.SearchOption.AllDirectories) .Where(s => s.EndsWith(".png") || s.EndsWith(".jpg")).ToArray(); } private void button2_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { folder = folderBrowserDialog1.SelectedPath; label2.Text = folder; } MovesImages(); } } }