频道分类

Delphi XE8 用HttpClient下载文件

作者:admin 来源: 日期:2020/3/20 23:52:54 人气: 标签:

 
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;

上一篇:DELPHI listview导出到excel下一篇:没有资料