Copy Files

Apr 11, 2009 at 8:25am
How do i copy files using Visual C++.
(Note:- I want to copy the file itself and not it's content)
Apr 11, 2009 at 9:44am
what do you mean with "I want to copy the file itself and not it's content" ?
Apr 11, 2009 at 12:28pm
I just did so many google searches and all I found about the topic was that they showed how to copy the content of the file using fstream.
The code is here:-
//start
std::ifstream ifs("input.txt", std::ios::binary);
std::ofstream ofs("output.txt", std::ios::binary);

ofs << ifs.rdbuf();
//end
I dont know whether the code works or not I want a code to copy the file itself(like when we select a file,right click on it and select copy) and not its content which the code does.
Last edited on Apr 11, 2009 at 12:30pm
Apr 11, 2009 at 12:52pm
So you want to copy the file on the clipboard?
Read this documentation at MSDN: http://msdn.microsoft.com/en-us/library/ms648709(VS.85).aspx
Apr 12, 2009 at 6:26am
I think he wants to move the file or make a copy of any file.

use CopyFile or CopyFileEx.

to move use rename()
Apr 12, 2009 at 10:29am
Thanks. That's what I wanted.
Topic archived. No new replies allowed.