hidrau
asked on
Use the idFtp event in runtime
Hi Guys,
The idFtp has an important event that gets the results, I don't know how to set / use the event when I create the idFtp in runtime. I need to
an example for it. Below you can see my code and use it to give me an example.
Thanks a lot
The idFtp has an important event that gets the results, I don't know how to set / use the event when I create the idFtp in runtime. I need to
an example for it. Below you can see my code and use it to give me an example.
Thanks a lot
Function RunFTP( FtpServidor , FtpUsuario, FtpSenha, FtpPorta, FtpAutentica, FtpCaminhoUpload, FtpCaminhoResposta: String): Boolean;
Result := True
if EstaVazio(FtpServidor) or EstaVazio( FtpUsuario ) or EstaVazio( FtpSenha ) or EstaVazio( FtpAutentica ) or
EstaVazio( FtpPorta ) {or EstaVazio( SmtpCaminhoUpload ) or EstaVazio( SmpCaminhoResposta )} then Begin
ShowMessage('As configurações de FTP não estão completas no parceiro: ' + CodCad);
Result := False;
Exit;
End;
if FtpAutentica = '1' then
FtpAut := true
else
FtpAut := false;
IdFTP1 := TIdFTP.Create();
IdFTP1.Disconnect;
IdFTP1.Host := FtpServidor;
idFTP1.DirectoryListing.DirectoryName:= FtpCaminhoUpload;
IdFTP1.Port := Strtoint(FtpPorta);
IdFTP1.Username := FtpUsuario;
IdFTP1.Password := FtpSenha;
IdFTP1.Passive := FtpAut;
try
IdFTP1.Connect;
except
IdFTP1.Disconnect;
IdFTP1.Connect;
Result := False;
Exit;
end;
BarraRotina('UP',Carquivo+iif(Tipo = 'Upload',' Envio ',' Recebimento ')+' de Arquivo '+Carquivo,0,0);
Try
Try
if Tipo = 'Upload' then begin
IdFTP1.Put (cArquivo, FtpCaminhoUpload+Carquivo, true);
end else if Tipo = 'Download' then begin
IdFTP1.Get ( FtpCaminhoResposta+Carquivo, Carquivo, true,false);
end else if Tipo = 'Delete' then begin
IdFTP1.delete ( FtpCaminhoUpload+Carquivo);
end;
Except
Result := false
End;
Finally
BarraRotina('UPC','Arquivo '+Carquivo+iif(Tipo = 'Upload',' Enviado ',' Recebido ')+' com sucesso',0,0);
End;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANKS
ASKER