.NET: How to copy files using Windows “Copy Files” dialog

眉间皱痕 提交于 2019-12-06 07:28:00

问题


.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.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.




回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!