TIdHTTP get下载文件

function Tform1.DownConfigreFile(var errmsg: string; url, name: string): boolean; 
var
  MyStream: TMemoryStream;
begin
  Result := true;
  MyStream := TMemoryStream.Create;
  try
    try
      httpUpdate.Get(url + name, MyStream);
      MyStream.SaveToFile(ExtractFilePath(Application.exename) + name);
    except
      on e: Exception do
      begin
        errmsg := e.Message; // 返回错误信息
        Result := false;
      end;
    end;
  finally
    MyStream.Free;
  end;
end;

  

posted @ 2018-04-16 13:46  夏天的西瓜君  阅读(208)  评论(0编辑  收藏  举报