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;
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.