1
I have 2 procedures, one compresses the file and the other sends it to FTP, but the upload process is running simultaneously with the compression process, and tries to send the file before the compression is finished.
procedure TForm2.compactacao;
var
sNomeArquivoCompactado, sDiretorioCompactar: string;
begin
sNomeArquivoCompactado := ObterDiretorioDoExecutavel + 'setup/lib.7z';
sDiretorioCompactar := ObterDiretorioDoExecutavel + 'bin\*';
try
ShellExecute(0, nil, '7z.exe',
PWideChar(' a -r ' + sNomeArquivoCompactado + ' ' + sDiretorioCompactar),' ', SW_SHOW);
except
On E: Exception do
begin
ShowMessage('Erro ao compactar: ' + E.Message);
// interrompe a compactacao
Abort;
end;
end;
log('Fim da compactação do arquivo de atualização');
end;
procedure TForm2.enviarArquivo;
begin
try
if ConectarServidorFTP = True then
IdFTP.Put(ObterDiretorioDoExecutavel+ 'setup\lib.7z','',False);
except
On E: Exception do
begin
// ignora a exceção "Connection Closed Gracefully"
if E is EIdFTPException then
Exit;
ShowMessage('Erro no upload : ' + E.Message);
// interrompe a atualização
Abort;
end;
end;
end;
Please put your code in the question, without it it becomes difficult to help.
– Roberto de Campos
Show examples of your code so we can analyze and help you
– GabrielLocalhost
I added the code of the 2 procedures
– LeandroRocha.me
You tried to use
TThread
?– Ilyes
Not yet, @Sami could give me an example?
– LeandroRocha.me
You have two ways, the first id to declare a boolean variable and check it periodically, if the value is "True", then run the second procedure, or you can use "Threads".
– Ilyes