如  *.*

解决方案 »

  1.   

    你要先遍历这个目录下的所有文件,CopyFile函数本身不能拷贝某一目录的所有文件。
      

  2.   

    FindFirstFile
    FindNextFile
    ...如果是MFC的话直接用CFileFind...
      

  3.   

    使用CFileFind类遍历所有的文件,取出各个文件名,再循环拷贝即可。
      

  4.   

    you can try SHFileOperation with flag FO_COPY
      

  5.   

    char Sou[_MAX_PATH];
    char Des[_MAX_PATH];
    SHFILEOPSTRUCT sfo;memset(Sou, 0, sizeof(Sou));
    strcpy(Sou, "C:\\Dir1");
    strcpy(Des, "C:\\Dir2"); //目录必须存在
    memset(&sfo, 0, sizeof(sfo));
    sfo.wFunc = FO_COPY;
    sfo.pFrom = Sou;
    sfo.pTo = Des;
    SHFileOperation(&sfo);注意,sfo.pFrom 和 sfo.pTo指向的字符串必须以2个0字符结尾。由于一
    开始我已经将Sou和Des全部清为0了,所以它们肯定是以2个0字符结尾的。
      

  6.   

    BOOL CMakeInstallFile::CopyNewFile(LPCTSTR pstr)
    {
    BOOL bResult = TRUE;
    CFileFind finder; CString strWildcard(pstr);
    strWildcard += _T("\\*.*"); // start working for files
    BOOL bWorking = finder.FindFile(strWildcard); while (bWorking)
    {
    bWorking = finder.FindNextFile();

    if (finder.IsDots())continue;

    if (finder.IsDirectory())
    {
    CString str = finder.GetFilePath();
    CString strSource = str;
    strSource.Replace(m_strVssFilePath, m_strInstallFilePath);
    bResult = ::CreateDirectory(strSource, NULL);
    if(!bResult)
    {
    ErrorOccur();
    }
    CopyNewFile(str);
    }
    else
    {

    CString strSource = finder.GetFilePath();
    CString strTarget = strSource; 
    strTarget.Replace(m_strVssFilePath, m_strInstallFilePath);
    bResult = ::CopyFile(strSource,strTarget,FALSE);
    MySetFileAttribute(strTarget);
    if(!bResult)
    {
    ErrorOccur();
    }
    else
    {
    m_pProgressCtrl->StepIt();
    }
    }
    } finder.Close(); return bResult;
    }
      

  7.   

    给你一个递归的
    CopyFolderAllFiles(CString csSourceFolder, CString csNewFolder)
    {
        CFileFind f;
        BOOL bFind=f.FindFile(csSourceFolder+"\\*.*");
    while(bFind)
    {
        bFind = f.FindNextFile();
            TRACE(_T("%s\r\n"),f.GetFileName());
    if(f.IsDots()) continue;
    if(f.IsDirectory())
        {
      _mkdir(csNewFolder+"\\"+f.GetFileName());
          CopyFolderAllFiles(csSourceFolder+"\\"+f.GetFileName(),csNewFolder+"\\"+f.GetFileName());
        }
    ::SetFileAttributes(csSourceFolder+"\\"+f.GetFileName(),FILE_ATTRIBUTE_NORMAL);
    ::AfxGetApp()->DoWaitCursor(1);
        ::CopyFile(csSourceFolder+"\\"+f.GetFileName(),csNewFolder+"\\"+f.GetFileName(),FALSE);
    ::AfxGetApp()->DoWaitCursor(-1);
    }
    }
      

  8.   

    jishiping(JSP 季世平) 的方法SHFileOperation(&sfo);
    是个不错的方法