看它的第三个参数,估计是文件已经存在了 bFailIfExists [in] Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds
bFailIfExists
[in] Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds
转义字符
CFileDialog fileDlg(FALSE, "ST", NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"文件类型(*.ST)|*.ST|", NULL);
CString csTemp;
if (fileDlg.DoModal() == IDOK) {
csTemp = fileDlg.GetFileName();
}
copyfile("data.txt", csTemp, TRUE);
我发现只有复制到当前目录时才能正确执行
csTemp.Replace("\\", "\\\\");
因此最后给它一个全路径。