Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

How to: Provide a Progress Dialog Box for File Operations (C# Programming Guide)

Updated: July 2008

The easiest way to provide a standard Windows progress dialog box when you perform file operations is to use the FileSystem object that is provided in the Microsoft.VisualBasic namespace.

NoteNote:

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To add a reference to Microsoft.VisualBasic.dll

  • In Visual Studio, open or create a project and then click Add Reference on the Project menu. On the .NET tab, select Microsoft.VisualBasic in the Component Name column.

To add a using directive

  • In your C# file, add the following line:

    using Microsoft.VisualBasic.FileIO;
    

The following code copies the directory specified by sourcePath into the directory specified by destinationPath. It also provides a standard Windows progress dialog box that shows the estimated time remaining before the operation finishes.

// Requires project reference to Microsoft.VisualBasic 
using Microsoft.VisualBasic.FileIO;
class FileProgress
{
    static void Main()
    {
        string sourcePath = @"C:\Users\public\documents\";
        string destinationPath = @"C:\testFolder";
        FileSystem.CopyDirectory(sourcePath, destinationPath,
            UIOption.AllDialogs);
    }
}

Date

History

Reason

July 2008

Added topic.

Content bug fix.

Community Additions

ADD
Show:
© 2015 Microsoft