title: Report progress in a WPF progress bar for the following method(s) in a button click?
body: <p>I have the following method that is executed in a button click:</p>
  
  <pre><code> private void CopyDirectoriesAndFiles(string source, string target, string[] excludedFolders)
          {
  
              foreach (string dir in Directory.GetDirectories(source, "*", System.IO.SearchOption.AllDirectories))
                  if (!excludedFolders.Contains(dir))
                      Directory.CreateDirectory(target + dir.Substring(source.Length));
  
              foreach (string file_name in Directory.GetFiles(source, "*.*", System.IO.SearchOption.AllDirectories))
                  if (!File.Exists(Path.Combine(target + file_name.Substring(source.Length))))
                      File.Copy(file_name, target + file_name.Substring(source.Length));
  
          }
  </code></pre>
  
  <p>The button  click has some other methods, but they don't take very long to run, but even so, how can I show and update a progress bar for each even that is run.  I put a textbox, but it only writes to the textbox once it is finished with everything.  My button order may looks like this:</p>
  
  <pre><code>InitializeStuff();
  
  CopyFiles();
  
  CleanUp();
  </code></pre>
  
  <p>A progress bar is not absolutely necessary, although nice.  It would be great if I could get my textbox to update at each time a method completed instead of at the very end.</p>