Thread th = new Thread(() => { // Directory.p if (!File.Exists(this.textBox1.Text)) { MessageBox.Show("拷贝的文件路劲有问题"); return; } else { CheckForIllegalCrossThreadCalls = false; using (FileStream fs = new FileStream(this.textBox1.Text, FileMode.Open)) { byte[] by = new byte[1024 * 1024]; long len = fs.Length; int i = fs.Read(by, 0, by.Length); long j = 0; using (FileStream fw = new FileStream(this.textBox2.Text, FileMode.Create)) { while (i != 0) { fw.Write(by, 0, i); i = fs.Read(by, 0, by.Length); j += i; progressBar1.Value = (int)(j * 100 / len); } } } progressBar1.Value = 100; this.button4.Text = "ok"; GC.Collect(); } }); th.Start();
时间: 2024-10-22 19:28:06