コード例 #1
0
        void DownloadCompletedHanlder(HttpDownloadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                lbSummary.Text =
                    String.Format("Received: {0}KB, Total: {1}KB, Time: {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;
            }
        }
コード例 #2
0
 protected virtual void OnDownloadCompleted(HttpDownloadCompletedEventArgs e)
 {
     if (DownloadCompleted != null)
     {
         DownloadCompleted(this, e);
     }
 }
コード例 #3
0
        void DownloadCompletedHanlder(HttpDownloadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                lbSummary.Text =
                    String.Format("Received: {0}KB, Total: {1}KB, Time: {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;
            }
        }
コード例 #4
0
        /// <summary>
        /// Handle DownloadCompleted event.
        /// </summary>
        void DownloadCompleted(object sender, HttpDownloadCompletedEventArgs e)
        {

            Invoke(new UIDownloadCompletedHanlder(DownloadCompletedHanlder), e);
            Logger.Log(new WebpageActionsLog(tbURL.Text, Actions.Download, OsirtHelper.GetFileHash(DownloadPath), Path.GetFileName(tbURL.Text), ""));
        }
コード例 #5
0
 /// <summary>
 /// Handle DownloadCompleted event.
 /// </summary>
 void DownloadCompleted(object sender, HttpDownloadCompletedEventArgs e)
 {
     Invoke(new UIDownloadCompletedHanlder(DownloadCompletedHanlder), e);
     Logger.Log(new WebpageActionsLog(tbURL.Text, Actions.Download, OsirtHelper.GetFileHash(DownloadPath), Path.GetFileName(tbURL.Text), ""));
 }
コード例 #6
0
 protected virtual void OnDownloadCompleted(HttpDownloadCompletedEventArgs e)
 {
     if (DownloadCompleted != null)
     {
         DownloadCompleted(this, e);
     }
 }