我正在尝试制作文件的副本。
此代码运行没有错误,但复制的文件不完整:
#include <iostream>
#include <filesystem>
using namespace std;
int main()
{
error_code ec;
filesystem::copy_file(
"C:/ProgramData/spectronix/oximeter/spectrumalpha.dat",
"C:/ProgramData/spectronix/oximeter/test.dat", ec );
cout << ec.value() << "\n";
return 0;
}
样品运行:
C:\ProgramData\spectronix\oximeter>dir
Volume in drive C is OS
Volume Serial Number is 86AE-5DBA
Directory of C:\ProgramData\spectronix\oximeter
2020-04-03 04:36 PM <DIR> .
2020-04-03 04:36 PM <DIR> ..
2020-04-03 01:29 PM 24,576 spectrum.dat
2020-03-23 12:27 PM 131,072 spectrumalpha.dat
2020-04-03 04:36 PM 963,072 test.exe
3 File(s) 1,118,720 bytes
2 Dir(s) 823,148,593,152 bytes free
C:\ProgramData\spectronix\oximeter>test
0
C:\ProgramData\spectronix\oximeter>dir
Volume in drive C is OS
Volume Serial Number is 86AE-5DBA
Directory of C:\ProgramData\spectronix\oximeter
2020-04-03 04:37 PM <DIR> .
2020-04-03 04:37 PM <DIR> ..
2020-04-03 01:29 PM 24,576 spectrum.dat
2020-03-23 12:27 PM 131,072 spectrumalpha.dat
2020-04-03 04:37 PM 7,409 test.dat
2020-04-03 04:36 PM 963,072 test.exe
4 File(s) 1,126,129 bytes
2 Dir(s) 823,148,515,328 bytes free
请注意,原始文件有 131,072 字节,但复制的文件只有 7,409 字节。