SHFileOperation
以拷贝为例。
CString strFrom = ....._T("src");
CString strTo = ....._T("dest\");
将strFrom文件夹及其下面的文件和子文件夹拷贝到 strTo下面
if (!PathFileExists(strTo))
{
CreateWindowDirectory(strTo);//创建目标文件夹,否则GetLastrError会得到 ERROR_INVALID_HANDLE错误
//strTo += _T("\");
//wstring new_sf = source_folder + L"\*";
WCHAR sf[MAX_PATH + 1];
WCHAR tf[MAX_PATH + 1];
wcscpy_s(sf, MAX_PATH, T2CW(strFrom));
wcscpy_s(tf, MAX_PATH, T2CW(strTo));
sf[lstrlenW(sf) + 1] = 0;
tf[lstrlenW(tf) + 1] = 0;
SHFILEOPSTRUCTW s = { 0 };
s.wFunc = FO_COPY;//拷贝,也可以指定删除等
s.pTo = tf;
s.pFrom = sf;
s.fFlags = FOF_SILENT | FOF_NOCONFIRMMKDIR | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NO_UI;
int res = SHFileOperationW(&s);
}