Exemple #1
0
        void DownloadCompletedHanlder(HttpDownloadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                lbSummary.Text =
                    String.Format("下载大小: {0}KB, 总大小: {1}KB, 用时: {2}:{3}:{4}",
                                  e.DownloadedSize / 1024, e.TotalSize / 1024, e.TotalTime.Hours,
                                  e.TotalTime.Minutes, e.TotalTime.Seconds);

                if (File.Exists(tbPath.Text.Trim()))
                {
                    File.Delete(tbPath.Text.Trim());
                }

                File.Move(tbPath.Text.Trim() + ".tmp", tbPath.Text.Trim());
                prgDownload.Value = 100;
            }
            else
            {
                lbSummary.Text = e.Error.Message;
                if (File.Exists(tbPath.Text.Trim() + ".tmp"))
                {
                    File.Delete(tbPath.Text.Trim() + ".tmp");
                }
                prgDownload.Value = 0;
            }
        }
 protected virtual void OnDownloadCompleted(HttpDownloadCompletedEventArgs e)
 {
     if (DownloadCompleted != null)
     {
         DownloadCompleted(this, e);
     }
 }
Exemple #3
0
 /// <summary>
 /// Handle DownloadCompleted event.
 /// </summary>
 void DownloadCompleted(object sender, HttpDownloadCompletedEventArgs e)
 {
     this.Invoke(new UIDownloadCompletedHanlder(DownloadCompletedHanlder), e);
 }