1

In an old question I found a link to an article which explains how to get the standard Windows Shell file copy progress dialog for your own file copy operations:

  1. Microsoft.VisualBasic.FileIO.FileSystem class members; (only supports copying 1 item at a time)
  2. A self-made interop for the IFileOperation API (very rudimentary)

The problem is that this article is a bit outdated - it was written over 4 years ago, before even VS2008 was out (oops, actually, it was released a month before the article. My bad. Still, the code in the article references VS2005), much less .NET 4.0. Since that, all answers I've seen here on SO seem to reiterate the same knowledge.

Could it be possible that this interop is already available somewhere in .NET 4.0 and you don't need to reimplement it anymore? If so, where can I access it?

Community
  • 1
  • 1
Vilx-
  • 104,512
  • 87
  • 279
  • 422
  • 1
    No. FileSystem.CopyDirectory() is still the .NET way, it still wraps the standard copy dialog. IFileOperation wasn't wrapped in the Windows API Code Pack. – Hans Passant Feb 22 '12 at 12:07
  • @HansPassant - OK. If you make it an answer, I'll accept it. – Vilx- Feb 22 '12 at 12:13

1 Answers1

0

Up to Windows XP you may use SHFileOperation: http://msdn.microsoft.com/en-us/library/windows/desktop/bb762164(v=vs.85).aspx

From Vista onwards you should use IFileOperation: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775771(v=vs.85).aspx

vulkanino
  • 9,074
  • 7
  • 44
  • 71
  • Beautiful. I know that. Read the question - it was about .net 4.0. – Vilx- Feb 22 '12 at 09:39
  • Glad to know you already knew it. But that is the way to do a file copy with a progress dialog. You may want to see this sample: http://msdn.microsoft.com/en-us/library/windows/desktop/dd940361(v=vs.85).aspx – vulkanino Feb 22 '12 at 09:51
  • I know that this is the way to do it. The question is - has .NET 4.0 already wrapped all these interfaces in managed objects, or must I do it myself? – Vilx- Feb 22 '12 at 10:03