简体   繁体   English

c#复制多个文件

[英]c# copy multiple files

I try to copy multiple files in c# from Folder A to Folder B. I filter the files I want to copy in my Code - after that for example the files 1 , 2 and 5 from Folder A should copy to Folder B. Therefor I want to use the Windows Copy Gui - because I want to see the the copy Progress bar and the Options if any file with the same already name exist. 我尝试将c#中的多个文件从文件夹A复制到文件夹B.我在我的代码中过滤要复制的文件 - 之后例如文件夹A中的文件1,2和5应该复制到文件夹B.因此我想要使用Windows Copy Gui - 因为我想查看复制进度条和选项,如果存在任何具有相同名称的文件。

I´ve found " How to bring up the built-in File Copy dialog? " this article. 我发现了“ 如何调出内置的文件复制对话框? ”这篇文章。 And I´ve tried to work with the following Options: 我尝试使用以下选项:

Filesystem.CopyFile Filesystem.CopyDirectory Filesystem.CopyFile Filesystem.CopyDirectory

But my Problem is: If I use CopyFile I only can copy ONE File... If I start the CopyFile Statement in loop the Windows Copy GUI will open and close for every file so I cant use the progressbar. 但我的问题是:如果我使用CopyFile我只能复制一个文件...如果我在循环中启动CopyFile语句,Windows Copy GUI将为每个文件打开和关闭,所以我不能使用进度条。

If I use CopyDirectory I only can Copy all files from Folder A to Folder B. 如果我使用CopyDirectory我只能将文件夹A中的所有文件复制到文件夹B.

So how can I copy multiple files from Folder A to Folder B with using the WINDOWS COPY GUI ??? 那么如何使用WINDOWS COPY GUI将多个文件从文件夹A复制到文件夹B.

Thank you. 谢谢。

It seems you are using VB.Net wrapper over native Windows API and the wrapper limits you. 看来你在本机Windows API上使用VB.Net包装器,包装器限制了你。 Probably, you can use those (or newer API's) directly and should search into I think you need to use IFileOperation.CopyItems , which accepts array of items as a source, but you'll have to write lots of interop code or find other samples. 也许你可以直接使用那些(或更新的API)并且应该搜索我认为你需要使用IFileOperation.CopyItems ,它接受项目数组作为源,但你必须编写大量的互操作代码或找到其他样本。

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

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