Can someone tell me why this processes all the files and then does it again? Its driving me crazy. Thanks
private void HP3BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker hp3worker = (BackgroundWorker) sender;
DirectoryInfo hp3Files = new DirectoryInfo(fromPath + @"\hp3\");
FileInfo[] hp3Filelist = hp3Files.GetFiles("*.*");
int count = hp3Filelist.Length;
UseWaitCursor = true;
for (int i = 0; i < count; i++)
{
FileInfo file = hp3Filelist[i];
try
{
File.Copy(fromPath + @"\hp3\" + file.Name, toPath + @"\hp3\" + file.Name, true);
hp3worker.ReportProgress((int)((float) i / count * 100));
}
catch (Exception error)
{
MessageBox.Show("Error is " + error);
}
}
UseWaitCursor = false;
}