Check also Multipart Multithreaded Downloading
procedure TfmTestDownloader.btDownLoadClick(Sender: TObject); begin if clDownloader1.IsBusy then Exit; clDownloader1.URL := 'http://www.clevercomponents.com/images/testimage.jpg'; clDownloader1.LocalFile := 'testimage.jpg'; clDownLoader1.Start(); end;
procedure TfmTestDownloader.StoreResourceInfo; var i: Integer; IniFile: TIniFile; begin IniFile := TIniFile.Create('set.ini'); try IniFile.WriteString('Download','URL', clDownLoader1.URL); IniFile.WriteString('Download','LocalFile', clDownLoader1.LocalFile); IniFile.WriteInteger('ResourceState', 'Count', clDownLoader1.ResourceState.Count); IniFile.WriteInteger('ResourceState', 'ResourceSize', clDownLoader1.ResourceState.ResourceSize); for i := 0 to clDownLoader1.ResourceState.Count - 1 do begin IniFile.WriteInteger('ResourceStateItem' + IntToStr(i), 'ResourcePos', clDownLoader1.ResourceState[i].ResourcePos); IniFile.WriteInteger('ResourceStateItem' + IntToStr(i), 'BytesToProceed', clDownLoader1.ResourceState[i].BytesToProceed); IniFile.WriteInteger('ResourceStateItem' + IntToStr(i), 'BytesProceed', clDownLoader1.ResourceState[i].BytesProceed); end; finally IniFile.Free(); end; end;
procedure TfmTestDownloader.RestoreResourceInfo; var i, cnt: Integer; IniFile: TIniFile; Item: TclResourceStateItem; begin clDownLoader1.ResourceState.Clear(); if not FileExists('set.ini') then Exit; IniFile := TIniFile.Create('set.ini'); try clDownloader1.URL:=IniFile.ReadString('Download', 'URL', ''); clDownloader1.LocalFile:=IniFile.ReadString('Download', 'LocalFile', ''); cnt := IniFile.ReadInteger('ResourceState', 'Count', 0); clDownLoader1.ResourceState.ResourceSize := IniFile.ReadInteger('ResourceState', 'ResourceSize', 0); for i := 0 to cnt - 1 do begin Item := clDownLoader1.ResourceState.Add(); Item.ResourcePos := IniFile.ReadInteger('ResourceStateItem' + IntToStr(i), 'ResourcePos', 0); Item.BytesToProceed := IniFile.ReadInteger('ResourceStateItem' + IntToStr(i), 'BytesToProceed', 0); Item.BytesProceed := IniFile.ReadInteger('ResourceStateItem' + IntToStr(i), 'BytesProceed', 0); end; finally IniFile.Free(); end; end;
procedure TfmTestDownloader.FormClose( Sender: TObject; var Action: TCloseAction); begin StoreResourceInfo(); end; procedure TfmTestDownloader.FormCreate(Sender: TObject); begin RestoreResourceInfo(); end;
Trouble logging in? Simply enter your email address OR username in order to reset your password.
For faster and more reliable delivery, add admin@clevercomponents.com to your trusted senders list in your email software.