Solved

Download full directory with tnmftp

Posted on 2000-05-12
2
436 Views
Last Modified: 2007-10-18
I need to download all files from a specific directory onto my local machine.  I am using tnmftp's download function but is there a way to tell it to download all files from a directory?
0
Comment
Question by:brettawv
  • 2
2 Comments
 
LVL 1

Accepted Solution

by:
Probie earned 50 total points
ID: 2804938
Drop an NMFTP component on the main form and make sure you have entered
the correct FTP, port and login properties.

There is no disconnection in the code below so if you want to disconnect
from the server you have to do this somewhere yourself.

Add the code below to your project
----


function FixPath(path : string) : string;
begin
 if IsPathDelimiter(Path,length(path)) then result := copy(path,1,length(path)-1) else result := path;
end;

function AttrDirectory(str : string) : boolean;
begin
 str := trim(str);
 result := (upcase(str[1]) = 'D');
end;

procedure TForm1.GetAllFiles(remotedir, localdir : string);
var lp0 : integer;
    localfile : string;
begin
 if NMFTP1.connected = false then NMFTP1.connect;
  if NMFTP1.connected then begin
   if DirectoryExists(FixPath(localdir)) then begin
    NMFTP1.ChangeDir(remotedir);
    NMFTP1.ParseList := true;
    NMFTP1.List;
    for lp0 := 0 to NMFTP1.FTPDirectoryList.name.Count-1 do begin
     if not AttrDirectory(NMFTP1.FTPDirectoryList.Attribute.Strings[lp0]) then begin
      LocalFile := FixPath(localdir)+'\'+NMFTP1.FTPDirectoryList.name.Strings[lp0];
      FFtp.Download(NMFTP1.FTPDirectoryList.name.Strings[lp0],LocalFile);
     end;
    end:
   end;
  end;
 end;
end;
0
 
LVL 1

Expert Comment

by:Probie
ID: 2804950
oppss...
I forgot to change the name in the download loop...

The name should be NMFTP1 not Fftp like in the example...
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question