Fórum Taxa de Download em componente TIDhttp #293596
29/08/2005
0
Bem comunidade, estou com o codigo abaixo e gostaria de saber como pegar a taxa de download, tempo aproximado e tempo restante para o download ser concluido. Alguém sabe como fazer ?
Existe tb um erro na funcao. Tipo se a internet do cara cair, ocorre uma exceção ? o try except nao ta tratando se alguem puder ajudar serei grato
[b:e1696dbb15]Evento on Work[/b:e1696dbb15]
Existe tb um erro na funcao. Tipo se a internet do cara cair, ocorre uma exceção ? o try except nao ta tratando se alguem puder ajudar serei grato
Function TForm1.Download( Host , url , local : String ) : Boolean; var Arquivo : string; FS : TFileStream; begin result := false; if Proxy.Ativo then Begin idHTTP1.Request.Username := Proxy.Username; idHTTP1.Request.Password := Proxy.Password; idHTTP1.Request.ProxyServer := Proxy.ProxyServer; idHTTP1.Request.ProxyPort := StrToIntDef(Proxy.ProxyPort , 80); end; idHTTP1.Host := Host; try IdHTTP1.Connect(); try Arquivo := idHttp1.Get( Url ); FS := TFileStream.Create( Local , fmCreate ); FS.Write(Arquivo[1], Length(Arquivo)); suiProgressBar1.Position := 0; result := true; except result := false; end; finally FS.Free; idHTTP1.Disconnect; end; End;
[b:e1696dbb15]Evento on Work[/b:e1696dbb15]
procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); begin ProgressBar1.Position := AWorkCount; Label5.Caption := FormatFloat(´,0.00´, AWorkCount div 1024 ) + ´ KB de ´ + FormatFloat(´,0.00´, ProgressBar1.Max div 1024 ) + ´ KB´; Application.ProcessMessages; Update; end;
Fknyght
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)