如何使用backgroundworker复制和过去 [英] How to copy and past with backgroundworker

查看:73
本文介绍了如何使用backgroundworker复制和过去的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一些文件从服务器复制并传递给客户端。

我想使用后台工作者

这是我的代码:

但不起作用



我尝试过:



i want to copy and past some file from server to client.
and i want to use backgroundworker
this is my code:
but doesnt work

What I have tried:

private void button1_Click(object sender, EventArgs e)
       {
           backgroundWorker1.RunWorkerAsync();
       }




private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
      {
           File.Copy(@"d:\f.mp4", @"d:\2\f.mp4");
      }

推荐答案

你可以但真的不喜欢这样。



这是一个谷歌搜索,它将为您提供许多不同的解决方案,以满足您的需求: c#异步复制文件 [ ^ ] - 选择您觉得最舒服的那个,因为您需要维护代码。
You could but really not like that.

Here is a google search that will give you lots of different solutions to do what you want: c# copy files asynchronously[^] - pick the one that you feel most comfortable with as you'll need you maintain the code.


这篇关于如何使用backgroundworker复制和过去的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆