private void download(FileInfo file, string source, Item f) { Directory.CreateDirectory(file.DirectoryName); try { WebClientMSJ download = new WebClientMSJ(); download.item = f; download.DownloadProgressChanged += new DownloadProgressChangedEventHandler(download_DownloadProgressChanged); download.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(download_DownloadFileCompleted); f.row.Cells[1].Value = "Downloading"; download.DownloadFileAsync(new Uri(source), file.FullName); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void download_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { WebClientMSJ client = sender as WebClientMSJ; client.item.row.Cells[2].Value = e.ProgressPercentage; }
void download_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { WebClientMSJ client = sender as WebClientMSJ; client.item.row.Cells[1].Value = "File Updated"; }