Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Download full directory with tnmftp

Posted on 2000-05-12
2
Medium Priority
?
462 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month20 days, 15 hours left to enroll

864 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