views:

295

answers:

6

Hello there,

.NET: How can I copy the files using Windows "Copy Files" dialog. I need to bulk copy multiple files. Does there exists any .NET 2.0 library/method that allows me to do it in crossplatform manner without invoking Windows platform specific libraries.

Thanks in advance.

+2  A: 

In order to use the "Windows 'Copy Files' Dialog" you will be required to invoke "Windows platform specific libraries."

Nate Bross
A: 

The problem is that it's not really "Windows's Copy Files' Dialog", it's Explorer's dialog. So, it's have to find a way to programmatically control Explorer. (May be possible via COM or WMI)

James Curran
SHFileOperation...
Roger Lipscombe
A: 

Maybe you'll find the needed functionality at the Windows API Code Pack

If everything else fails, it may work the ugly way: create an invisible Windows Explorer window, and manipulate it to start a copying process.

M.A. Hanin
+5  A: 

SHFileOperation, it is well supported by the standard .NET framework. Add a reference to Microsoft.VisualBasic.dll and use the Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory() method. Several overloads are available that allows you to control what the UI looks like and how to handle errors.

Hans Passant
+1 - Didn't know that! Thanks for the info.
Probably one of the best-kept secrets of VB.NET.
AMissico
A: 

In .NET you can make your own dialog.

It's not necessarily a difficult task though:

  • If you have VS2005 then unpack the VS2005ImageLibrary.zip located at C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary on a 64 bit system or C:\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary on a 32 bit system.

  • Once you have unpacked the zip file, there will several animated GIF's of the file copy dialog's animation. These also come in .AVI format.

  • Choose one of the animated GIFs.

  • Create a dialog with a picture box on it. Assign the GIF to the picture box's image property.

  • Add a label below the animation to specify what file is being copied.

  • Drive the file-copy operation using threads updating the dialog as necessary.

+1  A: 

Google for IProgressDialog - this is an Interface that gives you the functionality that you request

Sledge