Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6914693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:22:50+00:00 2026-05-27T09:22:50+00:00

I kinda have a problem. I’m trying to make a form that copies stuff

  • 0

I kinda have a problem. I’m trying to make a form that copies stuff from point A to B with a statusbar. Now the copying works fine but the statusbar just isn’t doing anything..
Anyone got any clue?

public partial class Form4A : Form
{
    public Form4A()
    {
        InitializeComponent();
        OtherSettings();
        BackgroundWorker.RunWorkerAsync(); // Starts wow copying
    }

    private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
    {
        string SourcePath = RegistryRead.ReadOriginalPath();
        string DestinationPath = RegistryRead.ReadNewPath();

        if (!Directory.Exists(SourcePath))
        {
            for (int i = 1; i <= 100; i++)
            {
                //Now Create all of the directories
                foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
                    SearchOption.AllDirectories))
                    Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));

                //Copy all the files
                foreach (string newPath in Directory.GetFiles(SourcePath, "*.*",
                    SearchOption.AllDirectories))
                    File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath));


                BackgroundWorker.ReportProgress(i);
            }
        }
    }
    private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        // Change the value of the ProgressBar to the BackgroundWorker progress.
        progressBar1.Value = e.ProgressPercentage;
        // Set the text.
        this.Text = e.ProgressPercentage.ToString();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:22:51+00:00Added an answer on May 27, 2026 at 9:22 am

    You say: if (!Directory.Exists(DestinationPath)). This means that the loop will never be executed, if the desination path exists. Make sure you delete the DestinationPath before you test your code!

    EDIT:

    if (Directory.Exists(SourcePath)) {
        //Now Create all of the directories 
        string[] allDirectories = Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories);
        string[] allFiles = Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories);
        int numberOfItems = allDirectories.Length + allFiles.Length;
        int progress = 0;
    
        foreach (string dirPath in allDirectories) {
            Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
            progress++;
            BackgroundWorker.ReportProgress(100 * progress / numberOfItems);
        }
    
        //Copy all the files 
        foreach (string newPath in allFiles) {
            File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath));
            progress++;
            BackgroundWorker.ReportProgress(100 * progress / numberOfItems);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a puzzling problem with trying to make an ajax/static state program. What
Hey, i have kinda silly problem, i need to set Point Pos as mouse
I have some code that runs fairly well, but I would like to make
Here's a problem that is kinda hard to explain. So here's an example. Let's
So here's my problem. I have a python script that takes a zipfile and
I have a kinda awkward problem, I'm working with C# and WPF in .NET
I've got the following problem: I have a set of LI elements that have
I have this problem that i want to transfer specific ( yet not that
I am having a kinda strange problem. Here is the situation. I have a
thank you for looking at my problem. I have an object that is being

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.