Delphi, FTP .

 

Delphi7

IdFTP(IdFTP) Indy Clients

 

 

 

// FTP

procedure TForm1.PutClick(Sender: TObject);

var

ftp: TIdFTP;

ms: TMemoryStream;

begin

ftp:=TIdFTP.Create(Application);

ms:=TMemoryStream.Create;

try

try

ftp.Host:='127.0.0.1';// ftp

ftp.Port:=21;

ftp.Username:='anonymous';//

ftp.Password:='';//

ftp.Connect(true, 2000);

AssErt(ftp.Connected);

ftp.ChangeDir('/');//

ftp.Put('c:\file.txt','file.txt',false); // -

ShowMessage('');

finally

ms.Free; ftp.Free;

end;

except

ShowMessage( );

end;

end;

//----Put---

 

// FTP

procedure TForm1.GetClick(Sender: TObject);

var

ftp: TIdFTP;

ms: TMemoryStream;

begin

ftp:=TIdFTP.Create(Application);

ms:=TMemoryStream.Create;

try

try

ftp.Host:='127.0.0.1'; // ftp

ftp.Port:=21;

ftp.Username:='anonymous'; //

ftp.Password:=''; //

ftp.Connect(true, 2000);

AssErt(ftp.Connected);

ftp.ChangeDir('/');//

ftp.Get('file.txt','c:\file.txt',true);// -

ShowMessage( );

finally

ms.Free; ftp.Free;

end;

except

ShowMessage ( );

end;

end;

//----Get---



<<