简体   繁体   English

如何“复制” Windows之类的文件

[英]How to “copy-paste” files like windows

I have a lot of files to copy, and I want to copy them like windows copy files: 我有很多文件要复制,我想像Windows复制文件一样复制它们:

first show the preparing window include the process bar, time remaining, speed, etc.), like this: 首先显示准备窗口,其中包括过程栏,剩余时间,速度等),如下所示:

在此处输入图片说明

And after that the "copying" window (include the process bar, time remaining, speed, etc.), like this: 然后,“复制”窗口(包括过程栏,剩余时间,速度等)如下所示:

在此处输入图片说明

I found at MSDN forum how to copy-paste one file ( link ): 我在MSDN论坛上发现了如何复制粘贴一个文件( 链接 ):

There is a system function called SHFileOperation, which has to be called via “P/Invoke”. 有一个称为SHFileOperation的系统函数,必须通过“ P / Invoke”调用。 To use it in easier manner, add a reference to Microsoft.VisualBasic assembly, then try this: 若要以更简单的方式使用它,请添加对Microsoft.VisualBasic程序集的引用,然后尝试执行以下操作:

using Microsoft.VisualBasic.FileIO; 使用Microsoft.VisualBasic.FileIO;

. . . .

FileSystem.CopyFile( @"source file", @"destination file", UIOption.AllDialogs ); FileSystem.CopyFile(@“源文件”,@“目标文件”,UIOption.AllDialogs);

In order to detect whether the operation was canceled by user, use a try-catch construct and intercept OperationCanceledException 为了检测操作是否被用户取消,请使用try-catch构造并拦截OperationCanceledException

My question: How can I copy-paste a list of files ? 我的问题:如何复制粘贴文件列表

Thank you 谢谢

What about using a DOS command? 使用DOS命令呢?

System.Diagnostics.Process.Start("CMD.exe","/C copy c:\\file.txt d:\\"); System.Diagnostics.Process.Start(“ CMD.exe”,“ / C复制c:\\ file.txt d:\\”);

For "executing dos commands without opening the console window" maybe this helps: http://www.developerstation.org/2009/04/c-executing-dos-commands-without.html 对于“在不打开控制台窗口的情况下执行dos命令”,这可能会有所帮助: http : //www.developerstation.org/2009/04/c-executing-dos-commands-without.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM