Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Ely88M
    Registrato dal
    Oct 2007
    Messaggi
    281

    [delphi] TdownloadURL

    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;

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,296
    Hai verificato che inserendo il percorso nel browser, il file venga effettivamente scaricato?
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.