Download() public méthode

Start to download.
public Download ( ) : void
Résultat void
Exemple #1
0
        /// <summary>
        /// Start to download.
        /// </summary>
        public void Download()
        {
            // Only idle download client can be started.
            if (this.Status != DownloadStatus.Initialized)
            {
                throw new ApplicationException(
                          "Only Initialized download client can be started.");
            }

            this.EnsurePropertyValid();

            // Set the status.
            this.Status = DownloadStatus.Downloading;

            if (!this.HasChecked)
            {
                string filename = null;
                this.CheckUrlAndFile(out filename);
            }

            HttpDownloadClient client = new HttpDownloadClient(
                this.Url.AbsoluteUri,
                0,
                long.MaxValue,
                this.BufferSize,
                this.BufferCountPerNotification * this.BufferSize,
                this.BufferCountPerNotification);

            // Set the HasChecked flag, so the client will not check the URL again.
            client.TotalSize    = this.TotalSize;
            client.DownloadPath = this.DownloadPath;
            client.HasChecked   = true;
            client.Credentials  = this.Credentials;
            client.Proxy        = this.Proxy;

            // Register the events of HttpDownloadClients.
            client.DownloadProgressChanged += client_DownloadProgressChanged;
            client.StatusChanged           += client_StatusChanged;
            client.DownloadCompleted       += client_DownloadCompleted;

            this.downloadClients.Add(client);
            client.Download();
        }
        /// <summary>
        /// Start to download.
        /// </summary>
        public void Download()
        {
            // Only idle download client can be started.
            if (this.Status != DownloadStatus.Initialized)
            {
                throw new ApplicationException(
                    "Only Initialized download client can be started.");
            }

            this.EnsurePropertyValid();

            // Set the status.
            this.Status = DownloadStatus.Downloading;

            if (!this.HasChecked)
            {
                string filename = null;
                this.CheckUrlAndFile(out filename);
            }

            HttpDownloadClient client = new HttpDownloadClient(
                    this.Url.AbsoluteUri,
                    0,
                    long.MaxValue,
                    this.BufferSize,
                    this.BufferCountPerNotification * this.BufferSize,
                    this.BufferCountPerNotification);

            // Set the HasChecked flag, so the client will not check the URL again.
            client.TotalSize = this.TotalSize;
            client.DownloadPath = this.DownloadPath;
            client.HasChecked = true;
            client.Credentials = this.Credentials;
            client.Proxy = this.Proxy;

            // Register the events of HttpDownloadClients.
            client.DownloadProgressChanged += client_DownloadProgressChanged;
            client.StatusChanged += client_StatusChanged;
            client.DownloadCompleted += client_DownloadCompleted;

            this.downloadClients.Add(client);
            client.Download();
        }