Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am manually copying some folders and files through C#, and I want to show the user that something is actually going on. Currently, the program looks as if its frozen, but it is actually copying files.

I would think there is already a built-in dialog or form that shows the process, similar to copying/moving files in windows explorer. Is there anything like that available, or will I have to create everything from scratch?

Also, would this be the best method to show the user that something is actively going on?

Thanks for the help!

like image 555
Pudpuduk Avatar asked Jun 14 '10 21:06

Pudpuduk


1 Answers

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);
like image 134
jsmith Avatar answered Sep 20 '22 22:09

jsmith