不知道为啥,在string后面必须要加 '\0';不然,有的 复制成功,有的 复制失败
string sFrom = currTemplatePart->GetPartPath() + currTemplatePart->GetpPartMain()->GetPartName();
sFrom += "\\*.*";
sFrom += '\0';
iDirection += '\0';
SHFILEOPSTRUCTA s = { 0 };
ZeroMemory(&s, sizeof(SHFILEOPSTRUCT));
s.hwnd = NULL;
s.wFunc = FO_COPY; // 复制
s.fFlags = FOF_NO_UI; // 不显示UI
s.pFrom = sFrom.c_str(); //必须有额外的'\0'结尾
s.pTo = iDirection.c_str(); //必须有额外的'\0'结尾
if (int iRet = SHFileOperationA(&s))
{
UF_print_syslog("复制失败!", true);
}
std::string sfrom= "D:\\python\\";
std::string iDirection = "D:\\1111111";
//sfrom.push_back('\0');
//iDirection.push_back('\0');
SHFILEOPSTRUCTA s = { 0 };
ZeroMemory(&s, sizeof(SHFILEOPSTRUCT));
s.hwnd = NULL;
s.wFunc = FO_COPY; // // 复制
s.fFlags = FOF_NO_UI; // // 不显示UI
s.pFrom = sfrom.c_str(); // //必须有额外的'\0'结尾
s.pTo = iDirection.c_str(); // //必须有额外的'\0'结尾
if(int iRet = SHFileOperationA(&s))
{
cout<<"复制失败"<<endl;
}