全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1902
推到 Plurk!
推到 Facebook!

Ftp 下載整個目錄的實現

缺席
hcker
中階會員


發表:95
回覆:118
積分:62
註冊:2003-02-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-06-29 01:16:54 IP:219.129.xxx.xxx 未訂閱
我這裏有段代碼 是屬於 D6控制項的,現在想改換成 D7 的Indy FTP 請問該如何實現 謝謝 function tftp.ex_download(remote_dir,local_dir:string):boolean; var i,j,count1:integer; att,ss:string; current_dir:string; temp_dir:string; begin try begin NMFTP1.ChangeDir(remote_dir); current_dir:=remote_dir; temp_dir:=copy(current_dir,2,length(current_dir)); if not DirectoryExists(local_dir) then CreateDir(local_dir); if not directoryexists(local_dir temp_dir) then createdir(local_dir temp_dir); nmftp1.ParseList:=true; NMftp1.list; count1:=nmftp1.FTPDirectoryList.name.Count; for i:=0 to count1-1 do begin file://必須 NMFTP1.ChangeDir(current_dir); nmftp1.list; ss:=nmftp1.FTPDirectoryList.name.Strings[i]; att:=nmftp1.FTPDirectoryList.Attribute.Strings[i]; if (copy(pchar(att),1,1)<>'d')and(copy(pchar(att),1,1)<>'D') then begin if not DirectoryExists(local_dir) then CreateDir(local_dir); NMFTP1.Download(current_dir ss,local_dir temp_dir ss); end else begin if not directoryexists(local_dir temp_dir ss) then createdir(local_dir temp_dir ss); file: ex_download(remote_dir ss '\',local_dir); end; end; result:=true; end except On E:Exception do begin result:=false; end; end; end; ----------要知道自己有多笨,到DelphiK.Top來看看----------
hcker
中階會員


發表:95
回覆:118
積分:62
註冊:2003-02-09

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-06-29 01:21:25 IP:219.129.xxx.xxx 未訂閱
procedure FTP_DownloadDir(var idFTP : TIdFtp;RemoteDir,LocalDir : string); label Files ; var i,DirCount : integer; begin if not DirectoryExists(LocalDir RemoteDir) then ForceDirectories(LocalDir RemoteDir); idFTP.ChangeDir(RemoteDir); idFTP.List(nil); DirCount := idFTP.DirectoryListing.Count ; if DirCount = 0 then begin idFTP.ChangeDirUp; idFTP.List(nil); end; for i := 0 to DirCount - 1 do begin if DirCount <> idFTP.DirectoryListing.Count then begin repeat idFTP.ChangeDirUp; idFTP.List(nil); until DirCount = idFTP.DirectoryListing.Count ; end; if idFTP.DirectoryListing[i].ItemType = ditDirectory then FTP_DownloadDir(idFTP,idFTP.DirectoryListing[i].FileName,LocalDir RemoteDir '\') else begin idFTP.Get(idFTP.DirectoryListing[i].FileName,LocalDir RemoteDir '\' idFTP.DirectoryListing[i].FileName,true); Form1.lb_num.Caption := IntToStr(StrToInt(Form1.lb_num.Caption) 1); Form1.lb_num.Update; if i = DirCount - 1 then begin idFTP.ChangeDirUp; idFTP.List(nil); end; end; end; end; ----------要知道自己有多笨,到DelphiK.Top來看看----------
系統時間:2024-04-19 21:03:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!