Гость
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Progress bar and download file by FTP with DELPHI / 4 сообщений из 4, страница 1 из 1
12.08.2021, 12:36
    #40090264
i7strelok
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Progress bar and download file by FTP with DELPHI
Hello comrades,

I am trying to download .ZIP files from an FTP server with Delphi 10.3.3.

To achieve this I am using the TIdFTP component and, apparently, it downloads well although I have the following problems:
- It downloads too slow.
- When I try to unzip it, I get an error in the head of the FTP file.

In addition to the aforementioned (and most importantly), I'm trying to place a progress bar (careful, it doesn't mean it has to be the TProgressBar component, that is, it can be any component). I personally have tried it with TProgressBar and with TGauge.

The problem is that I can't get the progress bar to work.

I've been reading a lot of links (Please use a translator because this is in Spanish) and a lot of people have experienced problems.

Link 1: http://www.clubdelphi.com/~hector/foros/showthread.php?t=56434
Link 2: http://www.clubdelphi.com/~marcsc/foros/showthread.php?t=59442

This I would swear it could work properly, but I don't know how to use it:

Link 3: https://stackoverflow.com/questions/17498198/indy-ftp-doesnt-load-correctly-a-progress-bar


It seems that when this line is executed, the program freezes and does not execute the following lines. Should I create a thread? Help, I don't know how to fix this:

Код: pascal
1.
   IdFTP1.Get('filename.extesion', 'destionationFolder', True, False);


Complete code of my function:

Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
procedure TfrmModulos.DownloadFile();
var
  sizeFtpFile: Integer;
begin
  TimerDescarga.enabled := True;
  barra.Enabled := True;
  sizeFtpFile:= IdFTP1.Size(cbModulosGSM.Items[cbModulosGSM.itemindex]);
  lblMessagesGSM.Caption := 'Check free disk space.';
  if FreeDiskSpace() > sizeFtpFile then
  begin
    barra.MaxValue := sizeFtpFile;// div 1024;
    IdFTP1.BeginWork(wmRead);
    Try
      IdFTP1.Get(cbModulosGSM.Items[cbModulosGSM.itemindex], ExtractFilePath(Application.ExeName) + cbModulosGSM.Items[cbModulosGSM.itemindex], True, False);
    Finally
      IdFTP1.EndWork(wmRead);
    end;
    if (FileExists(ExtractFilePath(Application.ExeName) + cbModulosGSM.Items[cbModulosGSM.itemindex])) then
    begin
       lblMessagesGSM.Caption := 'File '+cbModulosGSM.Items[cbModulosGSM.itemindex]+ ' downloaded.';
    end
    else
      lblMessagesGSM.Caption := 'Error '+cbModulosGSM.Items[cbModulosGSM.itemindex]+ '.';
  end
  else
  begin
     lblMessagesGSM.Caption := 'Hard disk full';
  end
end;
...
Рейтинг: 0 / 0
12.08.2021, 12:42
    #40090266
Dimitry Sibiryakov
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Progress bar and download file by FTP with DELPHI
You forgot to switch FTP into binary mode.
Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
12.08.2021, 16:41
    #40090371
DmSer
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Progress bar and download file by FTP with DELPHI
It seems that when this line is executed, the program freezes and does not execute the following lines. Should I create a thread?

It is desirable to create an additional thread and load data in it.
...
Рейтинг: 0 / 0
13.08.2021, 08:36
    #40090468
i7strelok
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Progress bar and download file by FTP with DELPHI
Dimitry Sibiryakov,

Спасибо товарищ Дмитрий

I have solved the FTP download problem, thanks to you. I have also solved the problem with the progress bar, for this I have used the third link.
...
Рейтинг: 0 / 0
Форумы / Delphi [игнор отключен] [закрыт для гостей] / Progress bar and download file by FTP with DELPHI / 4 сообщений из 4, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]