用HTTP从网站下载文件

该日志由 samool 发表于 2006-06-05 09:57:07

用HTTP从网站下载文件

方法一,用IdHttp:
procedure TForm1.Button1Click(Sender: TObject);
var
fs: TFileStream;
begin
fs := TFileStream.Create('c:\aaa.htm', fmCreate);
IdHTTP1.Get('http://www.abc.com/aaa.shtml', fs);
fs.Free;
end;

方法二,用UrlMon:
uses  
UrlMon


function DownloadFile(Source, Dest: string): Boolean;
begin
try
  Result := UrlDownloadToFile(nil, PChar(source), PChar(Dest), 0, nil) = 0;
except
  Result := False;
end;
end;

 
procedure TForm1.Button1Click(Sender: TObject);
begin
if DownloadFile(edit1.Text, edit2.Text) then
  ShowMessage('下载成功')
else ShowMessage('下载失败');
end;

该日志标签: none

上一篇: 今年夏天最流行的十大睡势
下一篇: 授权首发:千渡互通V1.0 内测版

当前暂无评论 »

添加新评论 »