现在我想写个函数,有两个参数,第一个参数是局域网中另一台机子上的虚拟目录地址“如http://192.168.1.200/xp”,第二个参数是文件名“如511127530223002.jpg”。现在我要通过这个函数将这张图片通过压缩下载到我机子上,代码如下:
uses
IdHTTP
function TForm1.getfile(Url, FileName: string): Boolean;
var
ms: TMemoryStream;
Http: TIdHttp;
begin
ms := TMemoryStream.Create;
Http := TIdHttp.Create(nil);
try
Http.Get(Url + '/' + FileName+'.jpg', ms );
ms.SaveToFile(FileName);
Result := True;
except
Result := False;
end;
Http.Free;
ms.Free;
end;