This is how I did it in the past:
void CopyAppFiles(string SourcePath, string )
{
foreach (string dirPath in Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories))
{
Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
}
foreach (string newPath in Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories))
{
File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
}
}
With progress you could do something like
void CopyAppFiles(string SourcePath, string )
{
string[] dirs = Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories);
string[] files = Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories)
int totalOperations = dirs.length + files.length;
for(int i = 0; i < dirs.length; i++)
{
Directory.CreateDirectory(dirs[i].Replace(SourcePath, DestinationPath));
ReportProgress(i, totalOperations);
}
for(int i = 0; i < files.length; i++)
{
File.Copy(files[i], files[i].Replace(SourcePath, DestinationPath), true);
ReportProgress(i + dirs.length, totalOperations);
}
}
void ReportProgress(int currentOperation, int totalOperations)
{
//TODO
}
works best with small files