1

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

9
  • 3
    Other suggestions would require us to understand your problem. So far you have only given us your idea of a solution. So how about you explain the problem. Why do you think this is a solution?
    – andy256
    Commented Jun 12, 2014 at 6:26
  • @andy256, Actually I'm not getting how to do this task. some Apps are there like tera copy and xcopy which says they do copy/paste work than windows default copy. By Other suggestion I mean is there any library (is case algo is not there) to do this.
    – Himanshu
    Commented Jun 12, 2014 at 6:32
  • It would be interesting if you add the examples you mention in your comment to the question's formulation.
    – logc
    Commented Jun 12, 2014 at 10:38
  • Your problem is not well defined. How much faster are you looking to copy? What are you copying (lots of small files, lots of large files, single/few large files, directory structures?). Simplistically speaking, there is no faster algorithm than reading the data and writing it somewhere else. That said, you can parallelize, you can map your inputs and outputs to memory pages for faster access, you can (probably) write your code to avoid page swaps, and so on. The correct solution would depend on some details (wich you have not provided).
    – utnapistim
    Commented Jun 12, 2014 at 10:53
  • @utnapistim I want to make a program in VC++ which can copy large data(files and folders more than 3-4 GB) from 1 directory to another and file transfer should be faster than windows copy program. that is my problem. I'm not getting how to do it.
    – Himanshu
    Commented Jun 13, 2014 at 4:24

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.