Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Visual C+中复制文件+;? 我使用Visual C++。如何将此文件的内容复制到另一个文件 UINT32 writeToLog(wstring log) { wfstream file1 (LOG_FILE_NAME, ios_base::out); file1 << log; file1.close(); // want to copy file1 to file2 return 0; } UINT32写日志(wstring日志) { wfstream file1(日志文件名,ios\U基::out); Fiel1标准C++没有文件复制工具,除了将文件读入内存并将其再次写入到不同的文件中。当您使用Windows时,您可以使用该函数-其他OSS具有类似的OS操作功能。 < P>您想做什么?如果您需要一个数据副本,可以在里面读取并将其写入OU。如果你真的需要文件的副本,你必须使用操作系统特定的调用_C++_Windows_Visual C++ - Fatal编程技术网

如何在Visual C+中复制文件+;? 我使用Visual C++。如何将此文件的内容复制到另一个文件 UINT32 writeToLog(wstring log) { wfstream file1 (LOG_FILE_NAME, ios_base::out); file1 << log; file1.close(); // want to copy file1 to file2 return 0; } UINT32写日志(wstring日志) { wfstream file1(日志文件名,ios\U基::out); Fiel1标准C++没有文件复制工具,除了将文件读入内存并将其再次写入到不同的文件中。当您使用Windows时,您可以使用该函数-其他OSS具有类似的OS操作功能。 < P>您想做什么?如果您需要一个数据副本,可以在里面读取并将其写入OU。如果你真的需要文件的副本,你必须使用操作系统特定的调用

如何在Visual C+中复制文件+;? 我使用Visual C++。如何将此文件的内容复制到另一个文件 UINT32 writeToLog(wstring log) { wfstream file1 (LOG_FILE_NAME, ios_base::out); file1 << log; file1.close(); // want to copy file1 to file2 return 0; } UINT32写日志(wstring日志) { wfstream file1(日志文件名,ios\U基::out); Fiel1标准C++没有文件复制工具,除了将文件读入内存并将其再次写入到不同的文件中。当您使用Windows时,您可以使用该函数-其他OSS具有类似的OS操作功能。 < P>您想做什么?如果您需要一个数据副本,可以在里面读取并将其写入OU。如果你真的需要文件的副本,你必须使用操作系统特定的调用,c++,windows,visual-c++,C++,Windows,Visual C++,在许多情况下,读入文件数据,然后再将其写入另一个文件,这与副本非常接近-如下所示: ifstream file1(...); ofstream file2(...); std::copy(istream_iterator<char>(file1),istream_iterator<char>(),ostream_iterator<char>(file2)); ifstream文件1(…); 流文件2(…); 复制(istream_迭代器(文件1)、istre

在许多情况下,读入文件数据,然后再将其写入另一个文件,这与副本非常接近-如下所示:

ifstream file1(...);
ofstream file2(...);
std::copy(istream_iterator<char>(file1),istream_iterator<char>(),ostream_iterator<char>(file2));
ifstream文件1(…);
流文件2(…);
复制(istream_迭代器(文件1)、istream_迭代器()、ostream_迭代器(文件2));
然而,这并不是一个拷贝——它正在创建一个具有相同内容的新文件。它不会正确处理硬链接或符号链接,它不会正确处理元数据,它只会“复制”数据


如果您需要Windows上的文件副本,您应该调用其中一个,或者根据您的具体要求。

Joe Gauterin的上述代码对我不起作用。我正试图复制一个.tga映像文件,因此可能是有关
istream\u迭代器的某个东西把它搞砸了。相反,我使用了:

ifstream file1(...);
ofstream file2(...);
char ch;
while(file1 && file1.get(ch))
{
  file2.put(ch);
}

我喜欢复制文件和复制数据之间的区别。这是我内心多年来一直知道的事情,但我从来没有见过它如此清晰地表达出来。天哪!