Download a directory using the FTP control

zhaozj2021-02-08  224

Download functions in the NMFTP control in Delphi can only download one file without providing a function that downloads the entire directory (containing subdirectory). I have written a method of implementing a directory download function, and users who need to use this feature can be referred to. // Catalog download 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 // must 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) ), 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); // recursive call ex_download (remote_dir ss '/', local_dir); end; end Result: = true; End Except ON E: Exception Do Begin Result: = FALSE; END; END;

http://www.softcows.com/cn

转载请注明原文地址:https://www.9cbs.com/read-3365.html

New Post(0)