如何在复制整个目录时更新进度条 [英] How to update a progress bar while copying entire directory

查看:164
本文介绍了如何在复制整个目录时更新进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想复制整个目录,我需要将目录源和目标路径发送到我要使用的方法或类。

有人可以帮助我吗?



我尝试了什么:



我尝试过:

https://www.codeproject.com/Answers/300184/Show-Progress-Bar-with-Copy-Folders-process#answer2

但无法在解决方案2中找到将类的源和目标路径发送到何处的路径。

解决方案

为了更新进度条,您需要执行此操作另一个线程中的副本 - 或复制操作阻止UI被更新。

最简单的方法是使用BackgroundWorker - 它允许你做的工作的肉一个线程,并提供显示进度的事件: BackgroundWorker Class (System.ComponentModel) [ ^ ]

I want to copy an entire directory, and I need to send the directory source and destination path to the method or class I am going to use.
Can someone please help me?

What I have tried:

I tried ths:
https://www.codeproject.com/Answers/300184/Show-Progress-Bar-with-Copy-Folders-process#answer2
but can't find where to send the source and destination paths to the class in solution 2.

解决方案

In order to update a progress bar, you need to do the copy in a different thread - or the copy operation prevents the UI being updated.
The easiest way to handle that is to use a BackgroundWorker - it allows you to do the "meat" of the job in one thread, and provides events to show the progress: BackgroundWorker Class (System.ComponentModel)[^]


这篇关于如何在复制整个目录时更新进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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