Form1.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 大文件拷贝
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            InitialProgressBar();
        }

        private void InitialProgressBar()
        {
            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
            progressBar1.Value = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string source = tb_source.Text.Trim();
            string target = tb_target.Text.Trim();
            Thread t1 = new Thread(new ThreadStart(() =>
            {
                BigFileCopy(source, target);
            }
            ));
            t1.IsBackground = true;
            t1.Start();

        }

        private void BigFileCopy(string source, string target)
        {
            using (FileStream fsRead = new FileStream(source, FileMode.Open, FileAccess.Read))
            {
                using (FileStream fsWrite = new FileStream(target, FileMode.Create, FileAccess.Write))
                {
                    byte[] array = new byte[1024 * 1024];
                    int count = fsRead.Read(array, 0, array.Length);
                    while (count > 0)
                    {
                        fsWrite.Write(array, 0, count);
                        progressBar1.Invoke(new Action<int>(
                    (num) => { progressBar1.Value = num; }
后面还有 13 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。