How to Bring Up the Built-In File Copy Dialog

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

Display Windows File Copy Dialog when copying from a Memorystream?

You can use Shell Progress Dialogs for this; this API exposes the dialog only, allowing you to use it to show the progress of any type of operation in your own application.

I wrote a managed wrapper for this a while ago, which you may find useful: Using Shell Progress Dialogs in Windows Forms Applications

How do I invoke the shell file copy dialog to report the progress of a copy in Win32?

Yes, this is what the SHFileOperation function is designed for. It accepts an SHFILEOPSTRUCT structure as its only parameter, which you can use to specify the options that you want.

However, it has been replaced in Windows Vista and later versions with the IFileOperation interface.

How do i bring up the windows 8.1 file copy dialogue box (one with the pause/resume functionality) from my c# code while copying a file?

IFileOperation is the interface that provides this functionality, but as it is a COM interface you need to use COM interop from C#.

There's an article about it in MSDN magazine.

Show a Copying-files dialog/form while manually copying files in C#?

There is one built in from the Microsoft.VisualBasic.FileIO Namespace. Don't let the name scare you, it is a very underrated namespace for C#. The static class FileSystem has a CopyFile and CopyDirectory method that has that capability.

FileSystem Members

Pay Close attention to the UIOption in both the CopyFile and CopyDirectory methods. This emulates displays the Windows Explorer copy window.

FileSystem.CopyFile(sourceFile, destinationFile, UIOption.AllDialogs);
FileSystem.CopyDirectory(sourceDirectory, destinationDirectory, UIOption.AllDialogs);

Copy many files and directories using the system file progress dialog?

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



Related Topics



Leave a reply



Submit