Fastest way to copy/paste a file to many destinations

What is the fastest way to copy a file located in:

C:\Test\copyMe.exe

to destinations:

1
2
3
4
F:\myNewName.exe
F:\My Music\myNewName.exe
F:\My Videos\myNewName.exe
F:\My Photos\myNewName.exe


Note 1: I'm not attempting to make a malicious program, the pathes chosen are just simple examples for testing.

Note 2: Files that are to be copied are executable files so the "weird" characters should be stored in variables large enough to be pasted fine.

Note 3: I'm talking about the run-time, not the time needed to write the code.
I tried using ifstream and ofstream but I had to change the destination variable name every time I want to paste the file somewhere so I don't think it's a good way to do it.
Last edited on
batch script?
It's a C++ forum
you asked what is a good way of doing it.
i would just write a simple batch script if you just want to transfer 4 files.

you can always pass parameters to your executable so when you run it you just specify the directories of where you want the file transferred.
so you don't need to keep recompiling your code every time your directory changes.
Last edited on
Are you serious? I asked for the fastest way to copy a file. Batch files are not even compiled, the simple command of xcopy C:\Test\copyMe.e F:\My Music\myNewName.exe /... would first, call the command interpreter to check if the line is valid, then call xcopy.exe with arguments specified which will also check if th syntax is valid before copying files. Also, to do this in a batch file you should write xcopy 4 times (for every destinations), so the source file will be reloaded every time. This is the slowest way of doing it.
if you are just going to copy a file into 4 different directories and rename it.
what is wrong with a batch script it only takes less than a second.

you have not specified how fast you want it to be.
is 1 second too slow for you.

its hard to give suggestions if you don't even give me something to work with. you haven't even shown your source code.
Last edited on
Are you serious? I asked for the fastest way to copy a file.

This is a good way to get help. Provide no meaningful details, then basically insult the first person to offer a suggestion.

I suggest looking into Boost's filesystem module. Here's a relevant link: http://www.boost.org/doc/libs/1_55_0b1/libs/filesystem/doc/reference.html#rename
I'm not insulting anybody, he answered the worst idea I could expect. I'd rather not use a third party library for such a simple script. Thanks for your suggestions anyway, I'll keep waiting for others.
@SkyWAGz
In case you are wondering, I reported you.
rafae11 gave you a valid solution to your problem and even if he hadn't the insults where unnecessary.
@naraku9333 did you even read the topic?
Note 3: I'm talking about the run-time, not the time needed to write the code.

I also said I want the fastest way, so at least I want a solution better tha the one I mentioned
I tried using ifstream and ofstream
So I think I'm the one who should report both of you.
Topic archived. No new replies allowed.