I use C # to copy files from one directory to another. I use the code from msdn, but it takes quite a minute or so to copy a couple of gigs. It only takes a few seconds in explorer. http://channel9.msdn.com/Forums/TechOff/257490-How-Copy-directories-in-C Awfully there is a faster way. :)
private static void Copy(string sourceDirectory, string targetDirectory) { DirectoryInfo diSource = new DirectoryInfo(sourceDirectory); DirectoryInfo diTarget = new DirectoryInfo(targetDirectory); CopyAll(diSource, diTarget); } private static void CopyAll(DirectoryInfo source, DirectoryInfo target) {
Using Parallel, I was able to copy 6 games per minute faster than explorer and xcopy.
private static void CopyAll(string SourcePath, string DestinationPath) { string[] directories = System.IO.Directory.GetDirectories(SourcePath, "*.*", SearchOption.AllDirectories); Parallel.ForEach(directories, dirPath => { Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath)); }); string[] files = System.IO.Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories); Parallel.ForEach(files, newPath => { File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath)); }); }
user1158903
source share