Controlling file downloads

后端 未结 2 543
感情败类
感情败类 2021-01-07 03:43

I am building an updater for my program with the use of a TWebBrowser. OnCreate the TWebBrowser navigates to the given URL. To download the update, the user is required to c

2条回答
  •  情深已故
    2021-01-07 04:24

    I would use Indy's TIdHTTP component for that, eg:

    uses
      ..., IdHTTP;
    
    var
      Url, LocalFile: String;
      Strm: TFileStream;
    begin
      Url := ...;
      LocalFile := ...;
      Strm := TFileStream.Create(LocalFile, fmCreate);
      try
        try
          IdHTTP.Get(Url, Strm);
        finally
          Strm.Free;
        end;
      except
        DeleteFile(LocalFile);
        raise;
      end;
    end;
    

提交回复
热议问题