Solved

Download full directory with tnmftp

Posted on 2000-05-12
2
432 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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now