最初代码如下:
CTime time_now__1;
time_now__1 = CTime::GetCurrentTime();
CString filename1="D:\\data\\result1\\不合格品 ";
CString filename2= time_now__1.Format("%Y_%m_%d %H:%M:%S");
CString filename3=".jpg";
CString filename4 = filename1 + filename2 + filename3;
ifstream in("D:\\data\\result2\\result1.jpg", ios::binary | ios::in);
ofstream out(filename4, ios::binary | ios::out);
out << in.rdbuf();
修改后就可以了:
CTime time_now__1;
time_now__1 = CTime::GetCurrentTime();
CString filename1="D:\\data\\result1\\不合格品 ";
CString filename2= time_now__1.Format("%Y_%m_%d %H_%M_%S");
CString filename3=".jpg";
CString filename4 = filename1 + filename2 + filename3;
ifstream in("D:\\data\\result2\\result1.jpg", ios::binary | ios::in);
ofstream out(filename4, ios::binary | ios::out);
out << in.rdbuf();
filename2中的 %H:%M:%S改为%H_%M_%S,为什么冒号不能用暂时也不清楚,如果有大神知道原因麻烦评论告知