To avoid repeated calls to
GetFiles()
, which could slow your application down considerably, get the files
once before starting the for loop.
FileInfo[] foundFiles = source_s.GetFiles();
for (int i = 0; i < foundFiles.Length; i++)
{
foundFiles[i].CopyTo(Path.Combine(dest_d.ToString(), foundFiles[i].Name), true);
}
or even
FileInfo[] foundFiles = source_s.GetFiles();
for (int i = 0; i < foundFiles.Length; i++)
{
FileInfo fi = foundFiles[i];
fi.CopyTo(Path.Combine(dest_d.ToString(), fi.Name), true);
}
which avoids another repeated data fetch.