Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Re: FTP a File

www.cryer.info
Managed Newsgroup Archive

Re: FTP a File

Subject:Re: FTP a File
Posted by:"Francois Piette [ICS & Midware]" (francois.piet..@overbyte.be)
Date:Thu, 4 May 2006 11:32:29

> Being pretty new to ftp'ing I get confused with all the stuff that's
> available. I need to start with a simple example and then I can work from
> there.
>
> Does anybody have some code that would enable me to ftp a small file up to
> an ftp server? I have all the ftp info etc and can easily do this via the
> cmd window. It would be nice to do it from code.

Using ICS (http://www.overbyte.be), create a new project, drop a button and
a memo on the main form.
Assign the events as below, then run.

procedure TForm1.Button1Click(Sender: TObject);
begin
    FtpClient1.HostName      := 'ftp.borland.com';
    FtpClient1.HostDirName   := 'pub/delphi/devsupport/general';
    FtpClient1.HostFileName  := 'index.txt';
    FtpClient1.UserName      := 'anonymous';
    FtpClient1.PassWord      := 'tom@company.com';
    FtpClient1.LocalFileName := 'c:\temp\index.txt';
    FtpClient1.ReceiveAsync;  // Or Receive if you want to be blocking
end;

procedure TForm1.FtpClient1Display(Sender: TObject; var Msg: String);
begin
     Memo1.Lines.Add(Msg);
end;

procedure TForm1.FtpClient1RequestDone(Sender: TObject;
  RqType: TFtpRequest; ErrCode: Word);
begin
    Memo1.Lines.Add('Done '  + IntToStr(ErrCode));
end;

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive