I have to copy quite a lot of files from one folder to another. Currently I am doing it in this way:
string[] files = Directory.GetFiles(rootFolder, '*.xml'); foreach (string file in files) { string otherFile = Path.Combine(otherFolder, Path.GetFileName(file)); File.Copy(file, otherFile); }
Is that the most efficient way? Seems to take ages.
EDIT: I am really asking if there is a faster way to do a batch copy, instead of copying individual files, but I guess the answer is no.
I can’t think of a more efficient way than File.Copy, it goes directly to the OS.
On the other hand if it takes that long, I would strongly suggest to show a progress dialog – like SHFileOperation does it for you. At least your users will know what is happening.