Advertisement

05.12.2008 at 03:55PM PDT, ID: 23396226
[x]
Attachment Details

Report Progress in ProgressBar and Label using backgroundWorker?

Asked by M_Lyons in C# Programming Language, Microsoft Visual C#.Net, Visual Studio .NET 2005

Tags: C#

I am trying to copy some files with a backgroundWorker, and want the progressBar and a label to be updated during the process.  I can't figure out how to do this though, and wanted to ask if anyone would be able to help me.  A helpful response will be greatly appreciated and marked as an answer.

Thanks Again,Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
string[] copyFile = { DirectoryTB1 };
                backgroundWorker1.DoWork += backgroundWorker1_DoWork;
                backgroundWorker1.RunWorkerAsync(copyFile);
 
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string DirectoryTextBox = copyFile[0].ToString();
                try
                {
                    using (ZipFile zip = new ZipFile(DirectoryTextBox + @"\Backup.zip"))
                    {
                        System.IO.Directory.SetCurrentDirectory(Environment.CurrentDirectory);
 
                        ProgressBar1.Visible = true;
                        Label2.Visible = true;
                        ProgressBar1.Value = ProgressBar1.Minimum;
 
                        //Add the Database File to the zip
                        zip.AddFile("DB.accdb");
                        Label2.Text = "Backing up Database...";
                        ProgressBar1.Increment(20);
 
                        //Add the Resources Folders and subdirectories to the zip
                        zip.AddItem("Files");
                        Label2.Text = "Backing up Files...";
                        ProgressBar1.Increment(70);
 
                        //Save the zip
                        zip.Save();
                        Label2.Text = "Database and Files Backed Up Successfully!";
                        ProgressBar1.Increment(10);
                    }
 
Loading Advertisement...
 
[+][-]05.12.2008 at 05:03PM PDT, ID: 21551393

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 06:52PM PDT, ID: 21551731

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.12.2008 at 06:54PM PDT, ID: 21551736

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Microsoft Visual C#.Net, Visual Studio .NET 2005
Tags: C#
Sign Up Now!
Solution Provided By: Idle_Mind
Participating Experts: 4
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628