问题
I've searched the web and stackoverflow for this.
I want to copy multiple files from multiple sources to multiple destinations. I don't bother with UnauthorizedAccessExceptions yet - the files are most likely to not be in use anyway.
I can copy 1 file using CopyFileEx-Wrapper from here. However: I'd like the standard windows copy file dialog to appear. And I'd like to copy multiple files - not just one - by e.g. passing an array of source files and an array of destination files.
Is there a way to do this? Further more: is there a way to queue this as one task and not x separated copy operations? The reason for this is the fact that I'd like to display only one progressing dialog - from the start till the end of copying all files.
I hope my question is clear.
Thank you all very much in advance.
divStar.
回答1:
Yes, this is possible with the IFileOperation shell interface, available since Vista. A managed class wrapper for this COM interface is available in the December 2007 issue of MSDN Magazine.
The Article is titled ".NET Matters: IFileOperation in Windows Vista"
The sample code is still available here.
Fall back on your existing code if it also needs to run on earlier versions of Windows.
回答2:
Set the MultiSelect property of your OpenFileDialog to true.
来源:https://stackoverflow.com/questions/3124038/copyfileex-with-multiple-files-but-only-one-copy-dialog