Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top