请问怎么用代码实现拷贝文件?在拷贝文件是怎么得知当前的进度?

解决方案 »

  1.   

    API函数拷贝文件夹
    void  OnFilecopy()
    {
         int nOk;
         char  strSrc[]="c:\\dos\0c:\\pwin98\\command\0";
         //可以改变源路径
         char  strDst[]="c:\\temp\0";
         //设置目的路径
         char  strTitle[]="File copying";
         //进度题头
         SHFILEOPSTRUCT FileOp;
         FileOp.hwnd=m_hWnd;
         FileOp.wFunc=FO_COPY;
         //执行文件拷贝
         FileOp.pFrom=strSrc;
         FileOp.pTo=strDst;
         FileOp.fFlags=FOF_ALLOWUNDO;
         FileOp.hNameMappings=NULL;
         FileOp.lpszProgressTitle=strTitle;        nOk=SHFileOperation(&FileOp);
            if(nOk)
                TRACE("There is an error: %d\n",nOk);
            else
               TRACE("SHFileOperation finished successfully\n");         if(FileOp.fAnyOperationsAborted)
      

  2.   

    CopyFile,不能知道,windows的进度条只是大约估计而已。
      

  3.   

    计算要拷贝的文件大小,然后调用系统的拷贝进度对话框,FAQ里有介绍。http://search.csdn.net/Expert/topic/1739/1739411.xml?temp=.9041864
      

  4.   

    BOOL CopyFile(
      LPCTSTR lpExistingFileName, // name of an existing file
      LPCTSTR lpNewFileName,      // name of new file
      BOOL bFailIfExists          // operation if file exists
    );
      

  5.   

    laiyiling(剑圣 VCFANS):
    那个拷贝好像不行的啊,提示“无法复制文件:无法读源文件或磁盘”,请问这是怎么回事啊?c:\\dos\0c:\\pwin98\\command\0 是文件夹还是文件啊?0c:是文件夹吗?
      

  6.   

    两个文件吧~~
    c:\\dos\0
    c:\\pwin98\\command\0