char strOldTitle[256];
ZeroMemory(strOldTitle,256);
strcpy(strOldTitle,sz);
strcat(strOldTitle,strDBdir);
strcat(strOldTitle,"title");
len = strlen(strOldTitle);
strOldTitle[len]='/0';
CreateDirectory("c://Program Files//title",NULL);
CopyFolder(strOldTitle, "c://Program Files");
BOOL CopyFolder(LPCTSTR lpszFromPath,LPCTSTR lpszToPath)
{
SHFILEOPSTRUCT FileOp;
ZeroMemory((void*)&FileOp,sizeof(SHFILEOPSTRUCT));
FileOp.fFlags = FOF_NOCONFIRMATION ;
FileOp.hNameMappings = NULL;
FileOp.hwnd = NULL;
FileOp.lpszProgressTitle = NULL;
FileOp.pFrom = lpszFromPath;
FileOp.pTo = lpszToPath;
FileOp.wFunc = FO_COPY;
return SHFileOperation(&FileOp) == 0;
}
复制出错一般都是给pFrom,pTo赋值出了错,我试了一下,直接:
pFrom = “c:/a”,pTo = “c:/b”也是不行的,有两种方法是可取的:
1.用c语言风格的字符串数组,(不要用c++的string类),我试过了
2.用MFC的CString类,没试过