A Simple Windows Download Manager
Downloads a batch list of links in the order they were added.
Designed to be as simplistic as possible
Add a list of links to the textbox on the left click add, each link will be added to the list on the right, click download and the files will be downloaded to the place you selected them to be saved to.
[VB] Visual Basic Projects - Simple Multi File Download Manager
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | Imports System.Net Imports System.IO Public Class Form1 Public DownloadLocation = "E:/Downloads" Dim SW As New Stopwatch Private Sub Button4_Click(sender As Object, e As EventArgs) Handles AddLinksToListBtn.Click 'Move links into list box For Each line In LinkListTextBox.Text.Split(vbNewLine) If line.ToString().Contains("http") Or line.ToString().Contains("https") Or line.ToString().Contains("www") Then LinkListListBox.Items.Add(line.ToString()) End If Next 'Clear out moved links from textbox LinkListTextBox.Clear() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles ClearLinkListBtn.Click LinkListListBox.Items.Clear() End Sub Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click DownloadLocation = SaveLocationTextBox.Text.ToString() End Sub Private WithEvents WebManager As WebClient Public StopDownload As Boolean = False 'Download Function Private Sub Button3_Click(sender As Object, e As EventArgs) Handles StartDownloadBtn.Click SW = Stopwatch.StartNew WebManager = New WebClient Dim LinkList As New List(Of String) For Each item As String In LinkListListBox.Items LinkList.Add(item.ToString()) Next For Each item In LinkList Dim strs = item.Split("/") CurrentLinkLabel.Text = item.ToString Label6.Text = SaveLocationTextBox.Text + strs(UBound(strs)).ToString 'error handling for bad uri Try WebManager.DownloadFileAsync(New Uri(item), SaveLocationTextBox.Text + strs(UBound(strs)).ToString) Catch ex As Exception MessageBox.Show(ex.ToString) End Try 'This stops the application from freezing while the webmanager is busy. Do While WebManager.IsBusy Application.DoEvents() If StopDownload Then WebManager.CancelAsync() StopDownload = False End If Loop Next 'clear the linklist LinkList.RemoveRange(0, LinkList.IndexOf(LinkList.Last)) End Sub Private Sub WebManager_DownloadProgressChanged(sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles WebManager.DownloadProgressChanged DownloadProgressBar.Maximum = Math.Round(e.TotalBytesToReceive / 1000000) DownloadProgressBar.Value = Math.Round(e.BytesReceived / 1000000) DownloadProgress.Text = e.ProgressPercentage.ToString() + "%" Label5.Text = "Download Speed: " + (Math.Round(e.BytesReceived / SW.ElapsedMilliseconds / 1000, 2, MidpointRounding.AwayFromZero)).ToString + "MB/s" If e.ProgressPercentage = 100 Then If LinkListListBox.Items.Count > 0 Then LinkListListBox.SelectedIndex = 0 If LinkListListBox.SelectedItem.ToString = CurrentLinkLabel.Text Then LinkListListBox.Items.Remove(LinkListListBox.SelectedItem) End If DownloadProgress.Text = "Completed" Label5.Text = "Download Speed: " + "0 MB/s" System.Threading.Thread.Sleep(250) DownloadProgress.Text = "" Label5.Text = "Download Speed: " CurrentLinkLabel.Text = "" Label6.Text = "Location: " DownloadProgressBar.Value = 0 End If End Sub Private Sub Button6_Click(sender As Object, e As EventArgs) Handles StopDownloadBtn.Click 'Stop Download Function StopDownload = True End Sub End Class |