如何从网上下载固定的几个文件,并且一次性的全部下载下来阿?总共有5-6个文件,总是下载到第4个左右的时候就下载不了了,大家帮忙看看。有没有什么好的自动断点续传,直到文件下载完毕的方法?idhttp如何判断下载过程是否已经中断了阿?谢谢,解决后立即三分。type
Tdownfile = class(TForm)
downhttp: TIdHTTP;
downidanti: TIdAntiFreeze;
downprogressbar: TProgressBar;
Edit1: TEdit;
Label1: TLabel;
filename: TLabel;
Button1: TButton;
procedure downhttpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure downhttpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
filelist:Tstringlist;
{ Public declarations }
end;
const
url='http://www.chinabis.net/plugs/';
var
downfile: Tdownfile;implementation{$R *.dfm}procedure Tdownfile.downhttpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
downprogressbar.Max:=AWorKcountMax;
downprogressbar.Min:=0;
downprogressbar.Position:=0;
end;procedure Tdownfile.downhttpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
downprogressbar.Position:=downprogressbar.Position+AWorKCount;
edit1.Text:=inttostr(downprogressbar.Position);
end;procedure Tdownfile.FormCreate(Sender: TObject);
begin
//初始化需要下载的文件
filelist:=Tstringlist.Create;
filelist.Add('nttrans.dll');
filelist.Add('livein.exe');
filelist.Add('ruyiso.dll');
filelist.Add('ruyiso.dat');
filelist.Add('imprint.ini');
end;procedure Tdownfile.Button1Click(Sender: TObject);
var
i:integer;
Mystream:Tfilestream;
begin
//下载文件
downidanti.OnlyWhenIdle:=false;
for i:=0 to filelist.Count-1 do
begin
mystream:=Tfilestream.Create('c:\123\'+filelist.Strings[i],fmcreate);
filename.Caption:=filelist.Strings[i];
try
downhttp.Get(url+filelist.Strings[i],mystream);
finally
mystream.Free;
downprogressbar.Position:=0;
end;
end;
showmessage('ok!');
end;
Tdownfile = class(TForm)
downhttp: TIdHTTP;
downidanti: TIdAntiFreeze;
downprogressbar: TProgressBar;
Edit1: TEdit;
Label1: TLabel;
filename: TLabel;
Button1: TButton;
procedure downhttpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure downhttpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
filelist:Tstringlist;
{ Public declarations }
end;
const
url='http://www.chinabis.net/plugs/';
var
downfile: Tdownfile;implementation{$R *.dfm}procedure Tdownfile.downhttpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
downprogressbar.Max:=AWorKcountMax;
downprogressbar.Min:=0;
downprogressbar.Position:=0;
end;procedure Tdownfile.downhttpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
downprogressbar.Position:=downprogressbar.Position+AWorKCount;
edit1.Text:=inttostr(downprogressbar.Position);
end;procedure Tdownfile.FormCreate(Sender: TObject);
begin
//初始化需要下载的文件
filelist:=Tstringlist.Create;
filelist.Add('nttrans.dll');
filelist.Add('livein.exe');
filelist.Add('ruyiso.dll');
filelist.Add('ruyiso.dat');
filelist.Add('imprint.ini');
end;procedure Tdownfile.Button1Click(Sender: TObject);
var
i:integer;
Mystream:Tfilestream;
begin
//下载文件
downidanti.OnlyWhenIdle:=false;
for i:=0 to filelist.Count-1 do
begin
mystream:=Tfilestream.Create('c:\123\'+filelist.Strings[i],fmcreate);
filename.Caption:=filelist.Strings[i];
try
downhttp.Get(url+filelist.Strings[i],mystream);
finally
mystream.Free;
downprogressbar.Position:=0;
end;
end;
showmessage('ok!');
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货