indy的问题(5分)

  • 主题发起人 jiegong_swpi
  • 开始时间
J

jiegong_swpi

Unregistered / Unconfirmed
GUEST, unregistred user!
我想用indy做一个通过http下载文件的程序,如何做?是不是用IdHTTP控件。
请详细点说明。谢谢!
 
是的,详细的:
procedure DownFile(sName, DName: string);
var
Response: TFileStream;
HttpDown: TIdHTTP;
begin
HttpDown := TIDHttp.Create(nil);
try
HttpDown.Request.ProxyPort := 80;
HttpDown.Request.ContentType := 'application/x-www-form-urlencoded';
Response := TFileStream.Create(DName, fmCreate);
try
HttpDown.Get(sName, response);
finally
Response.Free;
end;
finally
HttpDown.free;
end;
end;
 
在c++builder下代码不能编译通过。
我改为如下:
TFileStream *Response;
Response=TFileStream.Create("asdfas.txt", fmCreate);
HTTP->Get(url,Response);
 
下载文件还是用FTP好
 
顶部