Hello I have created a program that contains a btnCopy associated with a copyfiledialog, I would like to know why when I press the btnCopy it copies me several files at the same time, I would like that it copies the files one after the other, can will you help me?
private void btnCopy_Click(object sender,EventArgs e)
{
string sourceDir = @"C:\Users\PORTABLEHP\Documents";
string destDir = @"C:\Users\PORTABLEHP\Documents\xgen";
try
{
string [] txtList = Directory.GetFiles(sourceDir,"*.txt");
foreach (string f in txtList)
{
try
{
string fName = f.Substring(sourceDir.Length + 1);
string [] files = new string[sourceDir.Length];
progressBar1.Value = 1;
progressBar1.Minimum = 0;
progressBar1.Maximum = files.Length;
for(int i = 1;i < files.Length; i++)
{
progressBar1.PerformStep();
File.Copy(Path.Combine(sourceDir,fName),
Path.Combine(destDir,fName), true);
}
}
catch(IOException copyerror)
{
MessageBox.Show(copyerror.Message)
}
,