Please consider:
foreach (ListViewItem item in listViewFiles.Items)
{
// Display the ProgressBar control.
pBar1.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
pBar1.Minimum = 1;
// Set Maximum to the total number of files to copy.
pBar1.Maximum = 4; //filenames.Length;
// Set the initial value of the ProgressBar.
pBar1.Value = 1;
// Set the Step property to a value of 1 to represent each file being
copied.
pBar1.Step = 1;
string source=item.SubItems[0].Text.Trim();
string destination=item.SubItems[1].Text.Trim();
lisInfoList.Items.Add("Copying: " + source + " to " + destination);
File.Copy(source,destination,true);
item.SubItems[2].Text="Success";
// Perform the increment on the ProgressBar.
pBar1.PerformStep();
Application.DoEvents();
}
I set the Maximum to 4 because I know I only have 4 files for testing.
I can see the progressbar update very quickly to halfway on two of the
small files. The two larger 36MB files do not update the bar at all
until the end and then the blue bars on the ProgressBar only go up to
halfway when completed. What I am trying to do is have it so that each
file copied gets the ProgressBar a little closer to the end until they
are all copied. Thank you for any help.