Ciao a tutti.
devo fare il download di un file dal server... ho provato ad usare il TDownloadURL.
il mio programma funziona se il file da scaricare è .txt, ma nn va per tutti gli altri file...
sapete dirmi perchè?? mi potete dare una mano????
questo è il codice:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtActns, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
ProgressBar1: TProgressBar;
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
procedure URL_OnDownloadProgress
(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure Tform1.URL_OnDownloadProgress;
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
end;
procedure DoDownload;
var
downloadURL: TDownloadURL;
begin
downloadURL:=TdownloadURL.create(nil);
with downloadURL do
try
URL:='http://www.civites.it/prova.txt';
FileName := 'c:\prova.txt';
OnDownloadProgress := URL_OnDownloadProgress;
ExecuteTarget(nil);
showmessage('download completo');
finally
Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
dodownload;
end;