我正在尋找一些教程/源代碼來恢復暫停/中止下載。 我發現了源代碼,但我得到這個錯誤:德爾福「IdHTTP.Request.Range」屬性:未聲明標識符
procedure TForm1.Download(url, pathLocal : String);
var
eFile : TFileStream;
IdHTTP : TIdHTTP;
begin
idHTTP := TIdHTTP.Create(nil);
if FileExists(pathLocal) then //Caso o arquivo já exista ele o abre, caso contrário cria um novo
eFile := TFileStream.Create(pathLocal,fmOpenReadWrite)
else
eFile := TFileStream.Create(pathLocal,fmCreate);
try
try
eFile.Seek(0,soFromEnd); //Colocando o ponteiro no final do arquivo
IdHTTP.Head(url); //Buscando informações do arquivo
if eFile.Position < IdHTTP.Response.ContentLength then //Somente se o arquivo já não foi totalmente baixado
begin
IdHTTP.Request.ContentRangeStart := eFile.Position; //Definindo onde deve inciar o download
IdHTTP.Request.ContentRangeEnd := IdHTTP.Response.ContentLength; //Verificando o tamanho do arquivo
if eFile.Position > 0 then
begin //É importante que o range seja definido com o tamanho inicial e o final
IdHTTP.Request.Range := Format('%d-%d',[eFile.Position,IdHTTP.Response.ContentLength]);
end;
IdHTTP.Get(url,eFile);
end;
except
ShowMessage('Conexão interrompida.');
end;
finally
eFile.Free;
IdHTTP.Disconnect;
IdHTTP.Free;
end;
end;
這是錯誤:
Undeclared identifier: 'Range'
我怎樣才能解決這個問題?
我已經安裝了Indy 10,但是這個錯誤繼續.. 我正在使用Delphi 7 .. 請幫我:( – paulohr 2012-03-14 13:12:05