Solved

Download full directory with tnmftp

Posted on 2000-05-12
2
440 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…

792 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