DirectoryInfo src = new DirectoryInfo(@"E:\Test\Dir1");
DirectoryInfo dest = new DirectoryInfo(@"C:\Dir2");
CopyDirectory(src, dest);
static void CopyDirectory(DirectoryInfo source, DirectoryInfo destination)
{
if (!destination.Exists)
{
destination.Create();
}
FileInfo[] files = source.GetFiles();
foreach (FileInfo file in files)
{
file.CopyTo(Path.Combine(destination.FullName,
file.Name));
}
DirectoryInfo[] dirs = source.GetDirectories();
foreach (DirectoryInfo dir in dirs)
{
string destinationDir = Path.Combine(destination.FullName, dir.Name);
CopyDirectory(dir, new DirectoryInfo(destinationDir));
}
}
change directories according to your requirements