C++ – Algorithm to Copy data faster than windows default copy provider

algorithmsc

I need an algorithm which can copy data(files/folder) from one place to another, faster than windows default copy/paste option. I'm working in vc++. Is there any algorithm by which I can do copy/paste faster.
Or Is there is any other suggestion to perform this task?
Thanks

Best Answer

The Windows copy/paste function has several components.

  • A cute GUI interface
  • Pre-analysis of the work to be done, to help the GUI provide nice feedback and detect conflicts
  • Essentially single tasking
  • A very fast internal API for copying files.

In my opinion you are unlikely to be able to write code that can beat the Windows CopyFile() API function. You can however use multi-threading to saturate the IO channel and if you also omit the cute GUI stuff and the pre-analysis then that's probably as fast as you can go.

You can test this quite easily by running several XCOPY tasks at the same time and watching the resource monitor to see when you reach the maximum IO throughput.

One final thought: if you're copying a lot of small files there may be advantages in copying files that are located close together to minimise disk head movement. You would need to test to find out whether that is a factor.