TFtpClient.LocalFileName

From Overbyte
Revision as of 00:53, 11 September 2006 by Kbrad1 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Main page -> ICS component reference -> TFtpClient -> LocalFileName

Definition

property LocalFileName: string;

Default Value

None

Description

Property used when transferring files to and from the server.

Required by Put, PutAsync, Get, and GetAsync.

Example

// Button OnClick Event
procedure TFtpAsyncForm.Button1Click(Sender: TObject);
begin
  FtpClient1.HostName := 'ftp.simtel.net';
  FtpClient1.Port := 'ftp';
  FtpClient1.UserName := 'anonymous';
  FtpClient1.Password := 'john.smith@mycomp.com';
  FtpClient1.HostDirName := '/pub/simtelnet';
  FtpClient1.OpenAsync;                            // Non-blocking open.
end;

// FtpClient1 OnRequestDone Event
procedure TFtpAsyncForm.FtpClient1RequestDone(Sender: TObject; RqType: TFtpRequest; ErrCode: Word);
begin
  // If error then close connection and exit;
  if ErrCode <> 0 then begin
    Display('Error #' + IntToStr(ErrCode));
    if (FtpClient1.Connected) then
      FtpClient1.QuitAsync;
    Exit;
  end;

  try
    case RqType of
      ftpOpenAsync:    FtpClient1.UserAsync;        // Open successful
      ftpUserAsync:    FtpClient1.PassAsync;        // User successful
      ftpPassAsync:    FtpClient1.CwdAsync;         // Password successful
      ftpCwdAsync:     FtpClient1.TypeSetAsync;     // CWD successful
      ftpTypeSetAsync:                              // Set type successful
        begin
          FtpClient1.HostFileName := 'simtel40.gif';
          FtpClient1.LocalFileName := 'C:\simtel40.gif';
          FtpClient1.GetAsync;
        End;
      ftpGetAsync:     QuitAsync;

      else
        Application.MessageBox('Unexpected RqType ' + IntToStr(Ord(RqType)), 'FTP', MB_OK);
      end;
   except
     on E:Exception do begin
       Application.MessageBox('*** ' + E.Message + ' ***', 'FTP', MB_OK);
     end;
   end;
end;

Best Practices

How To