Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TWebCopy
Download files only when newer version than local copy is available

With TWebCopy, the component to upload or download files via HTTP / FTP, it is easy to instruct the component to only start a download when a newer file version is available online. To do this, all that needs to be done is set the option WebCopyItem.CopyNewerOnly = true and set the date to check against via WebCopyItem.FileDate. In this case, we’d set this date to the local file date:

procedure TForm5.CheckAndDownloadNewDoc;
var
  wci: TWebCopyItem;
begin
  WebCopy1.Items.Clear;

  wci := WebCopy1.Items.Add;
  wci.URL := 'https://download.tmssoftware.com/download/manuals/TMS%20Spell%20Check.pdf';
  wci.CopyNewerOnly := true;
  wci.FileDate := FileAge(''c:\Doc\TMS%20Spell%20Check.pdf'');
  wci.TargetDir := ''c:\doc'';

  WebCopy1.Execute;

  if wci.NoNewVersion then
    ShowMessage(''No new version found'')
  else
    ShowMessage(''New file from ''+DateToStr(wci.NewFileDate) + '' found'');
end;