I have two string lists: name (contains file names), url (contains file urls). I would like to download all neccessary files using THttpget in one loop, with a progress bar:
for d:=0 to numberOfDownloads-1 do
begin
HTTPGet2.URL:=url[d];
HTTPGet2.FileName:=name[d];
HTTPGet2.GetFile;
end;
It works, but it downloads only one file - first on the string list. How can I do that? numberOfDownloads - number of items in the stringlist name.
HTTPGet downloads a file asynchronously, by creating a secondary thread and notifying thru standard events.
So, in your case, when you iterate over the loop and get to the second file to download, the HTTPGet2 instance is still busy processing the previous download.
One simple way to overcome this is to create an array of HTTPGet instances... something like this...
and to get notified of the finalization events, you need to create your own OnDoneFile and set it...