见上

解决方案 »

  1.   

    procedure TSetupFrm.copyPathFile(strSourFilePath:string;DeFieldpath:string);
    var
     OpStruc:TSHFileOpStruct;
      FromBuf,ToBuf:Array[0..128] of Char;
    begin
      try     FillChar(FromBuf,Sizeof(FromBuf),0);
        FillChar(ToBuf,Sizeof(ToBuf),0);   
        StrPCopy(FromBuf,Pchar(strSourFilePath)); 
    strSourFilePath
        StrPCopy(ToBuf,Pchar(DeFieldpath));
        
        with OpStruc do
        begin
          Wnd:=Handle;
          wFunc:=FO_COPY;
                                                                
          pFrom:=@FromBuf;
          pTo:=@ToBuf;
          fFlags:=FOF_NOCONFIRMATION or FOF_MULTIDESTFILES or FOF_SIMPLEPROGRESS;// or FOF_RENAMEONCOLLISION;
          fAnyOperationsAborted:=False;
          hNameMappings:=nil;
          lpszProgressTitle:=nil;
        end;         
        if SHFileOperation(OpStruc)=0 then
        begin                                                      
        end;
      except
        raise Exception.Create('出错');
      end;
    end;
      

  2.   

    procedure Tmainform.FileCopy(const Fromfile,Tofile:string);
    Var
       F1,F2:file;
       NumRead,Numwritten:integer;
       Buf:array [1..2048] of char;
    Begin
       AssignFile(F1,Fromfile);
       Reset(F1,1);
       AssignFile(F2,Tofile);
       Rewrite(F2,1);
       Repeat
          BlockRead(F1,buf,sizeof(buf),NumRead);
          BlockWrite(F2,buf,Numread,NumWritten);
       Until (NumRead=0) or (NumWritten<>NumRead);
       CloseFile(F1);
       CloseFile(F2);
    End;