VC任意拷贝文件目录及其子目录到目的地

来源:互联网 发布:广元历史湿度数据查询 编辑:程序博客网 时间:2024/06/10 08:45

#include <WTypes.h>  
#include <ShellAPI.h>  
#include <tchar.h>  
#include <WinNT.h>  
#pragma comment(lib, "shell32.lib") 

 

 

 

 

 ///
 SHFILEOPSTRUCT lpsh;
 ZeroMemory(&lpsh, sizeof(lpsh));
 lpsh.hwnd = HWND_DESKTOP;
 lpsh.fFlags = FOF_RENAMEONCOLLISION;  // 有重名文件时自动添加“复件”前缀
 lpsh.wFunc = FO_COPY;   // 拷贝文件
 lpsh.pFrom ="e:\\Courses" ;//tmpsrcpath   // 源文件路径
  lpsh.pTo ="c:\\" ;//tmpdespath   // 目标路径
   if (0 != SHFileOperation(&lpsh))
    {
    AfxMessageBox("fail");
     }
   else
   {
    AfxMessageBox("success");
   }