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.
Click one, then, while holding down the Ctrl key, click all the others, one at a time. The right-click one them and choose Cut. Finally, go to the new folder, right-click there, and choose Paste.
Method 1: Right-click Go to the location where stores your file or folder (hard drive, USB, etc.). Click the name of the file or folder you wish to copy. Right-click the highlighted file or folder and click Copy. Go to the destination folder, right-click the destination folder and click Paste.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With