How to bring up the built-in File Copy dialog?

Answer taken from: here

Windows Vista does indeed include a new copy engine that supports exactly what you’re looking to do. However, it’s possible that previously existing functionality may meet your needs. For example, if you want to copy, move, rename, or delete an individual file or directory, you can take advantage of SHFileOperation (exposed from shell32.dll), which is already wrapped by the Visual Basic® runtime. If you’re using Visual Basic 2005, you can simply use functionality from the My namespace, for example:

 My.Computer.FileSystem.CopyDirectory(
   sourcePath, destinationPath, UIOption.AllDialogs)

Accomplishing the same thing in C# involves only a little more work, adding a reference to Microsoft.VisualBasic.dll (from the Microsoft® .NET Framework installation directory) and using code such as the following:

using Microsoft.VisualBasic.FileIO;
...
FileSystem.CopyDirectory(
    sourcePath, destinationPath, UIOption.AllDialogs);

When run, this will result in the same progress UI you’d see if you were doing the same file operations from Windows Explorer. In fact, when running on Windows Vista, you automatically get the new Window Vista progress UI, as shown in Figure 1. Dialog

Leave a Comment