- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi XE8 用HttpClient下载文件
uses System.Net.HttpClient;
function DownloadFile(const URL:string; const filename:string):boolean;
var
ms:tmemorystream;
hc:thttpclient;
begin
ms:=tmemorystream.Create;
hc:= thttpclient.Create;
try
try
hc.Get(URL,ms);
ms.SaveTofile(filename);
result:=true;
except
on e: Exception do
ApplicationShowException(e);
end;
finally
hc.Free;
ms.Free;
end;
end;