2007年9月23日星期日

Copy File in C/C++

How to copy file in C/C++ or rename a file?
1) Use System command.
system("copy sourcefile.txt destinyfile.txt");

2)
#include
#include

int main() {
std::ifstream infile("src.dat", std::ios_base::binary);
std::ofstream outfile("dest.dat", std::ios_base::binary);
outfile << infile.rdbuf(); }

3)

使用copy函数,file.copy("fromfile.txt","toFile.txt");

4) Simple C/C++ Perfometer: Copying Files (Versions 4.x)
http://groups.google.com/group/perfo/msg/8a74465da4c4e9bb
上面是最详细的使用各种方法进行文件拷贝的介绍,以及速度测试。

没有评论: