Below is the routine I'm using:
Code: Select all
Function Download_File(Const wURL_Address, wLocal_Filename: String; var wError_Message: String): Boolean;
var
wScHttpWebRequest: TScHttpWebRequest;
wFileStream: TFileStream;
wScHttpWebResponse: TScHttpWebResponse;
begin
Result:=False;
wError_Message:='';
if FileExists(wLocal_Filename) then Begin
If Not DeleteFile(wLocal_FileName) Then Begin
wError_Message:='Could not delete the file';
Exit;
End;
End;
wScHttpWebRequest:=TScHttpWebRequest.Create(wURL_Address);
Try
wScHttpWebResponse:=TScHttpWebResponse.Create;
Try
wFileStream:=TFileStream.Create(wLocal_Filename, fmCreate);
Try
Try
wScHttpWebRequest.IPVersion:=ivIPBoth;
wScHttpWebRequest.SSLOptions.IgnoreServerCertificateValidity:=False;
wScHttpWebRequest.Proxy.Address := zprPROXY;
wScHttpWebRequest.Proxy.Port := StrToIntDef(zprPORTA, 8080);
wScHttpWebRequest.Proxy.Credentials.UserName := zprUSER_PROXY;
wScHttpWebRequest.Proxy.Credentials.Password := zprPWD_PROXY;
wScHttpWebResponse:=wScHttpWebRequest.GetResponse;
wScHttpWebResponse.ReadToStream(wFileStream);
Result:=True;
Except
On E: SysUtils.Exception do
wError_Message := E.Message;
End;
Finally
wFileStream.Free;
End;
Finally
wScHttpWebResponse.Free;
End;
Finally
wScHttpWebRequest.Free; //<---AV on this line
End;
end;
I'm using SecureBridge 9.5.1 with Delphi 10.4.2.
Thank you