C++資料夾深度拷貝問題
阿新 • • 發佈:2020-12-15
void CopyFiles(const CString &strSrcPath, const CString &strDstPath) { SHFILEOPSTRUCT fops; TCHAR source[MAX_PATH] = { 0 }; _tcscpy(source, strSrcPath); // 原始檔夾 TCHAR dest[MAX_PATH] = { 0 }; _tcscpy(dest, strDstPath); // 目標資料夾 fops.hwnd = ::GetActiveWindow(); fops.wFunc = FO_COPY; fops.pFrom = source; fops.pTo = dest; fops.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR || FOF_SILENT; fops.hNameMappings = NULL; fops.lpszProgressTitle = NULL; int result = ::SHFileOperation(&fops); }
注意檔案路徑中不能帶有“\\”、“\\\”等連續的多個反斜槓,那樣是讀取不出來的