5、利用控件TVCLZip和TIdFTP压缩文件并上传到FTP的线程单元pas 改进版
2015-04-10 16:27
537 查看
用到临界区 保护写日志的函数;
递归函数 删除目录下的所有文件;
循环创建或判断FTP的目录;
可改进的地方:循环压缩深层次目录的所以文件; 实现断点续传,或断点下载;
断点上传和断点下载代码
递归函数 删除目录下的所有文件;
循环创建或判断FTP的目录;
可改进的地方:循环压缩深层次目录的所以文件; 实现断点续传,或断点下载;
procedure TFrmFTP_ZIP.btnBreUpLoadClick(Sender: TObject); var tStream: TFileStream; Size1:Integer; begin if IdFTP1.Connected then begin if not UploadOpenDialog1.Execute then Exit; tStream:=TFileStream.Create(UploadOpenDialog1.FileName,fmOpenRead ); try Size1 :=IdFTP1.Size(ExtractFileName(UploadOpenDialog1.FileName)); if Size1 >0 then //这样判断文件是否存在 是错误的。 begin case MessageDlg('文件已经存在,是否续传?', mtConfirmation, mbYesNoCancel, 0) of mrYes: begin tStream.Position:=Size1; //tStream.Seek(IdFTP1.Size('Delphi大量pdf资料非扫描档1.zip'),0) ; //也可以。 IdFTP1.Put(tStream,ExtractFileName(UploadOpenDialog1.FileName),true); //续传 end; mrNo: begin IdFTP1.Put(tStream,ExtractFileName(UploadOpenDialog1.FileName),False); //重新传 end; mrCancel: Exit; //取消 end; end else IdFTP1.Put(tStream,ExtractFileName(UploadOpenDialog1.FileName),False); { tStream.Position:=IdFTP1.Size('Delphi大量pdf资料非扫描档1.zip'); //当前路径的指定文件 //tStream.Seek(IdFTP1.Size('Delphi大量pdf资料非扫描档1.zip'),0) ; //也可以。 IdFTP1.Put(tStream,'Delphi大量pdf资料非扫描档1.zip',true); } finally tStream.Free; end; end else ShowMessage('Ftp未连接'); end; procedure TFrmFTP_ZIP.btnBreDownLoadClick(Sender: TObject); begin if IdFTP1.Connected then begin if FileExists('Delphi大量pdf资料非扫描档1.zip') then begin case MessageDlg('文件已经存在,是否续传?', mtConfirmation, mbYesNoCancel, 0) of mrYes: FtpDownLoad( 'Delphi大量pdf资料非扫描档1.zip', True); //续传 mrNo: FtpDownLoad( 'Delphi大量pdf资料非扫描档1.zip', False); //覆盖 mrCancel: Exit; //取消 end; end else FtpDownLoad( 'Delphi大量pdf资料非扫描档1.zip', False); //建立新文件下载 end else ShowMessage('Ftp未连接'); end;
断点上传和断点下载代码
相关文章推荐
- 5、利用控件TVCLZip和TIdFTP压缩文件并上传到FTP的线程单元pas
- 利用Indy的TIdFtp控件实现FTP协议, 远程下载上传文件
- Delphi7 中利用Indy的TidFtp客户端控件实现在服务器指定目录下下载需要的文件
- C# 利用Rar压缩文件并FTP上传
- 利用.NET的File控件上传文件的最终解决方案
- 利用ASP.NET设计FTP文件上传(中)
- 利用.NET的File控件上传文件的最终解决方案(个人版)
- 利用.NET的File控件上传文件的最终解决方案(个人版)
- 利用ASP.NET设计FTP文件上传
- 利用ASP.NET设计FTP文件上传(中)
- 利用ASP.NET设计FTP文件上传(上)
- 利用ASP.NET设计FTP文件上传(下)
- 利用.NET的File控件上传文件的最终解决方案
- 利用Indy的TIdFtp控件实现FTP协议 for http://www.cittm.net/Article/sheji/delphi/200601/1227.html
- 利用.NET的File控件上传文件技巧
- 利用ASP.NET设计FTP文件上传(上)
- 利用FTPClient类实现文件的上传下载功能
- [转]利用.NET的File控件上传文件的最终解决方案(个人版)
- 利用.NET的File控件上传文件的最终解决方案
- 利用.NET的File控件上传文件的最终解决方案