public static void CopyDirectory(string sourceDir, string destDir) { if (Directory.Exists(destDir) == false) { Directory.CreateDirectory(destDir); } destDir += "\\"; var files = Directory.GetFiles(sourceDir); foreach (var file in files) { FileInfo flinfo = new FileInfo(file); flinfo.CopyTo(destDir + flinfo.Name, true); } var dirs = Directory.GetDirectories(sourceDir); foreach (var path in dirs) { DirectoryInfo dirInfo = new DirectoryInfo(path); CompareUtil.CopyDirectory(path, destDir + dirInfo.Name); } }