显示一个复制,文件对话框/表格,而手动复制在C#中的文件吗? [英] Show a Copying-files dialog/form while manually copying files in C#?
问题描述
我通过手动C#复制一些文件夹和文件,我想表明的东西实际上是怎么回事用户。目前,该方案的看起来的,如果它的冷冻,但它实际上是复制文件。
I am manually copying some folders and files through C#, and I want to show the user that something is actually going on. Currently, the program looks as if its frozen, but it is actually copying files.
我想已经有一个内置的对话框或形式显示的过程中,类似于复制/ Windows资源管理器移动文件。有没有这样的可用的东西,否则我将不得不从头开始创建一切?
I would think there is already a built-in dialog or form that shows the process, similar to copying/moving files in windows explorer. Is there anything like that available, or will I have to create everything from scratch?
此外,这是否表明事情正在积极准备对用户的最佳方法?
Also, would this be the best method to show the user that something is actively going on?
感谢您的帮助!
推荐答案
有一个内置从 Microsoft.VisualBasic.FileIO 命名空间。不要让名字糊弄你,这是C#一个非常低估的命名空间。静态类文件系统
有一个 CopyFile
和 CopyDirectory
方法具有这种能力。
There is one built in from the Microsoft.VisualBasic.FileIO Namespace. Don't let the name fool you, it is a very underrated namespace for C#. The static class FileSystem
has a CopyFile
and CopyDirectory
method that has that capability.
密切关注的 UIOption
在两个 CopyFile
和 CopyDirectory
方法。这模仿Windows资源管理器窗口复制
Pay Close attention to the UIOption
in both the CopyFile
and CopyDirectory
methods. This emulates the Windows Explorer copy window.
FileSystem.CopyFile(sourceFile, destinationFile, UIOption.AllDialogs);
FileSystem.CopyDirectory(sourceDirectory, destinationDirectory, UIOption.AllDialogs);
这篇关于显示一个复制,文件对话框/表格,而手动复制在C#中的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!