CopyFileEx with multiple files, but only one copy dialog
Asked Answered
C

2

4

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.

Cordy answered 26/6, 2010 at 13:36 Comment(0)
R
5

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.

Rooke answered 26/6, 2010 at 13:48 Comment(1)
Thank you :D. It does do exactly what I want it to - too bad I should check whether my application runs on Windows Vista or 7 before involving that functionality..Cordy
M
1

Set the MultiSelect property of your OpenFileDialog to true.

Michelinamicheline answered 26/6, 2010 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.