编程语言
首页 > 编程语言> > C++文件夹深度拷贝问题

C++文件夹深度拷贝问题

作者:互联网

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);
}

注意文件路径中不能带有“\\”、“\\\”等连续的多个反斜杠,那样是读取不出来的

标签:fops,dest,TCHAR,C++,source,FOF,文件夹,拷贝
来源: https://blog.csdn.net/qq_42608732/article/details/111169801