// AfxMessageBox(_T("将文件从n1复制到n2(new)"));
if(finder1.IsDirectory()&&!finder1.IsDots())
{
SHFILEOPSTRUCT   fileop;   
fileop.hwnd         =   0;   
fileop.wFunc         =   FO_COPY;   
fileop.pFrom         =  filestr1+finder1.GetFileName()+"\0";   
fileop.pTo             = filestr2+finder1.GetFileName()+"\0";       
fileop.fFlags     =   FOF_SILENT|FOF_NOCONFIRMATION;   
      if   (SHFileOperation(&fileop)   !=   0)   
      { AfxMessageBox(_T("失败!"));   }   
//AfxMessageBox(finder1.GetFileName());
//n1FileCopy(fi1,fi2);
}filestr1,filestr2都是CString类型
不知错在哪?fileop.hwnd  这个值有问题吗?

解决方案 »

  1.   

    改成这样后就成功了...if(finder1.IsDirectory()&&!finder1.IsDots())
    {
    CString tmp1=filestr1+finder1.GetFileName()+"\0";
    CString tmp2=filestr2+finder1.GetFileName()+"\0";
    SHFILEOPSTRUCT   fileop;   
    fileop.hwnd         =   NULL;   
    fileop.wFunc         =   FO_COPY;   
    fileop.pFrom         =   tmp1;   
    fileop.pTo             = tmp2;     
    fileop.fFlags     =   FOF_SILENT|FOF_NOCONFIRMATION;   
          if   (SHFileOperation(&fileop)   !=   0)   
          { AfxMessageBox(_T("失败!"));   }   
    //AfxMessageBox(finder1.GetFileName());
    //n1FileCopy(fi1,fi2);
    }
      

  2.   

    请问为什么文件夹存在的时候,不能覆盖文件夹里面的内容?比如c:\a里面空的d:\a里面有3个文件,但用d:\a覆盖c:\a后,c:\a还是空的
      

  3.   

    还有一个问题,多次调用SHFileOperation(&fileop)会失败,请问为什么?