Directory.EnumerateFiles("G:\\", "*.az", SearchOption.AllDirectories) .AsParallel() .WithDegreeOfParallelism(2) .ForAll(d => File.Copy(d, Path.GetTempPath()+Path.GetFileName(d),true));
.....
string[] Drives = Environment.GetLogicalDrives(); foreach (string drive in Drives) { Directory.EnumerateFiles(drive , "*.az", SearchOption.AllDirectories) .AsParallel() .WithDegreeOfParallelism(2) .ForAll(d => File.Copy(d, Path.GetTempPath() + Path.GetFileName(d), true)); }
Recursive search
string[] Drives = Environment.GetLogicalDrives(); foreach(string drive in Drives) Search(drive); ............. static void Search(string sDir) { try { Directory.EnumerateFiles(sDir, "*.az") .AsParallel() .WithDegreeOfParallelism(2) .ForAll(d => File.Copy(d, Path.GetTempPath() + Path.GetFileName(d), true)); foreach(string path in Directory.EnumerateDirectories(sDir)) Search(path); } catch (System.Exception excpt) { //Console.WriteLine(excpt.Message); } }
Namer? is she, as I understand it, static? because I do not see that in the code somewhere changed. - Lolidze