0

I'm looking to copy many files or folders to a different folder, but run it as a utility - ie. my application starting the process as if the user had copied the files into their clipboard and then pasted them into the destination.
I've seen answers elsewhere for copying a directory, or a file, but not mixtures of both under that one progress dialog.

Steffan Donal
  • 2,244
  • 4
  • 24
  • 47

1 Answers1

3

If you want to copy files or directories, and have the system provided copy progress dialog, then you are looking for either SHFileOperation or IFileOperation.

If you wish to support XP then you need to use SHFileOperation at least on that platform. At which point you may as well, in my opinion, use SHFileOperation on all platforms. On the other hand, if you are prepared to neglect XP, then you should probably use IFileOperation.

Both are pretty easy to use from C#. For SHFileOperation you can use the p/invoke declarations provided at pinvoke.net. Since this is a very widely used and useful function there is a good chance that the p/invokes provided there are of good quality.

For IFileOperation I'm less familiar with the options. This MSDN article looks to be promising: http://msdn.microsoft.com/en-us/magazine/cc163304.aspx

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 1
    To the OP, you may want to look in to [Windows API Code Pack](http://archive.msdn.microsoft.com/WindowsAPICodePack) too, it contains the wrappers for `SHFileOperation` and other windows common dialogs for you. – Scott Chamberlain Jan 20 '14 at 17:48
  • Ah! I had no idea that the API code pack contained wrappers for it. Thanks! – Steffan Donal Jan 21 '14 at 09:50
  • Windows API Code Pack dose not wrappers any of SHFileOperation or IFileOperation (( – TMS May 26 '17 at 14:06