问题
.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.
回答1:
In order to use the "Windows 'Copy Files' Dialog" you will be required to invoke "Windows platform specific libraries."
回答2:
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.
回答3:
Google for IProgressDialog - this is an Interface that gives you the functionality that you request
回答4:
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.
回答5:
In .NET you can make your own dialog.
It's not necessarily a difficult task though:
If you have VS2005 then unpack the
VS2005ImageLibrary.ziplocated atC:\Program Files (x86)\Microsoft Visual Studio 8\Common7\VS2005ImageLibraryon a 64 bit system orC:\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibraryon 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
imageproperty.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.
回答6:
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)
来源:https://stackoverflow.com/questions/2561570/net-how-to-copy-files-using-windows-copy-files-dialog