Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Windows Native Copy and Move Progress Bar from C# Windows Form App

Tags:

I was wondering if we could give the open source community this logic, using which the C# Windows Form App Developers can integrate the copy and move native window box like this -

enter image description here

Can we even do this? Because whatever threads I have came across while searching for this provide their own Progress Bar in Windows App.

like image 387
Thompson Avatar asked Aug 31 '17 14:08

Thompson


1 Answers

What comes unnatural is that you have to add a reference to the assembly Microsoft.VisualBasic in your C# project.

enter image description here

And then add the correct namespace at the top of your .cs file:

using Microsoft.VisualBasic.FileIO;

Here is the "C#" code (that really is nothing more the a call to the correct method) to invoke FileSystem.CopyDirectory

private void button1_Click(object sender, EventArgs e)
{
    FileSystem.CopyDirectory(
        @"c:\src",
        @"c:\dst",
        UIOption.AllDialogs,
        UICancelOption.DoNothing);
}

And that will generate the desired eye candy for you with having to deal with any Progressbar handling on your own.

progress dialog

like image 151
rene Avatar answered Nov 02 '22 22:11

rene