我如何使用http.get for delphi xe2 ios firemonkey?

时间:2011-12-29 11:18:54

标签: delphi http delphi-xe2 firemonkey

用于获取备忘录中页面源代码的组件或代码。 谢谢

1 个答案:

答案 0 :(得分:2)

//It works on Win32/Win64/OS X !

procedure TMainForm.Button_DownloadClick(Sender: TObject);
const
  URL      = 'http://web.t-online.hu/karpo/downloads/3dc32480.zip';

var
  fsSource: TFileStream;
  FILENAME_Local: String;

begin
  {$IFDEF MSWINDOWS}
     FILENAME_Local:=ExtractFilePath(ParamStr(0))+'proba.zip';
  {$ENDIF}

  {$IFDEF MACOS}             //OS X user !
     FILENAME_Local:='/users/zoltankarpati/public/proba.zip';
  {$ENDIF}

  if FileExists(FILENAME_Local) then
  begin
    fsSource := TFileStream.Create(FILENAME_Local, fmOpenWrite);
  end
  else
  begin
    fsSource := TFileStream.Create(FILENAME_Local, fmCreate);
  end;

  try
    IdHTTP.Get(URL, fsSource);
  finally
    fsSource.Free;
  end;
end;