Thursday، February 09، 2006

دانلود کردن یک فایل از اینترنت

سورس کد زیر را می توانید برای دانلود یک فایل از طریق اینترنت استفاده نمائید.

فراموش نکنید که در ابتدای برنامه حتما یونیت اشاره شده در ابتدای سورس را فراخوانی کنید.




uses ExtActns, ...

type
TfrMain = class(TForm)
...
private
procedure URL_OnDownloadProgress
(Sender: TDownLoadURL;
Progress, ProgressMax: Cardinal;
StatusCode: TURLDownloadStatus;
StatusText: String; var Cancel: Boolean) ;
...

implementation
...

procedure TfrMain.URL_OnDownloadProgress;
begin
ProgressBar1.Max:= ProgressMax;
ProgressBar1.Position:= Progress;
end;

function DoDownload;
begin
with TDownloadURL.Create(self) do
try
URL:='http://z.about.com/6/g/delphi/b/index.xml';
FileName := 'c:\ADPHealines.xml';
OnDownloadProgress := URL_OnDownloadProgress;

ExecuteTarget(nil) ;
finally
Free;
end;
end;

{
Note:
URL property points to Internet
FileName is the local file
}




در همین زمینه :

بد نیست بدانید چطور می توان فهمید که کامپیوتر به اینترنت متصل هست یا نه؟