Я создал приложение для копирования файлов с компьютера на usb автоматически. Но я не знаю, как завершить копию при завершении отображения сообщения
[
image . When the copy is 100% complete, the thing I need to add is display the completion message]
Что я уже пробовал:
Я использовал этот метод копирования :
public Form1() { InitializeComponent(); driveDetector = new DriveDetector(); driveDetector.DeviceArrived += new DriveDetectorEventHandler(OnDriveArrived); driveDetector.DeviceRemoved += new DriveDetectorEventHandler(OnDriveRemoved); } private void OnDriveArrived(object sender, DriveDetectorEventArgs e) { if (checkBox2.Checked) { Process.Start("anti.bat"); } string s = e.Drive + " Phát hiện thiết bị mới ."; dinfo(); listBox1.Items.Add(s); label10.Text = listBox1.Items.Count.ToString(); label10.Refresh(); listBox1.Refresh(); label6.Refresh(); label4.Refresh(); if (textBox1.Text == "") { } else { // string dir = e.Drive; // dir.Remove(1, 1); // comboBox1.Text = dir; Thread thread = new Thread(() => { try { string copy1 = textBox1.Text; FileSystem.CopyDirectory( copy1, e.Drive, UIOption.AllDialogs, UICancelOption.DoNothing); } catch (Exception ex) { MessageBox.Show("Error : " + "Kiểm tra lại đường dẩn COPY", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); thread.Start(); } } private void OnDriveRemoved(object sender, DriveDetectorEventArgs e) { string s = e.Drive + " Phát hiện thiết bị mới ."; listBox1.Items.Remove(s); label10.Text = listBox1.Items.Count.ToString(); label10.Refresh(); listBox1.Refresh(); label6.Text = ""; label4.Text = ""; comboBox1.Text = ""; } private void buttonClose_Click(object sender, EventArgs e) { this.Close(); } private void button1_Click(object sender, EventArgs e) { FolderBrowserDialog folderDlg = new FolderBrowserDialog(); folderDlg.ShowNewFolderButton = true; // Show the FolderBrowserDialog. DialogResult result = folderDlg.ShowDialog(); if (result == DialogResult.OK) { textBox1.Text = folderDlg.SelectedPath; Environment.SpecialFolder root = folderDlg.RootFolder; } }
Afzaal Ahmad Zeeshan
Что?