Option Strict Off
Option Explicit On
Imports System.Windows.Forms
Imports System.Diagnostics
Imports System.Net
Imports System.ComponentModel
Public Class Dialog3
Dim myClient As New Net.WebClient
Private Sub DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs)
ProgressBar1.Value = e.ProgressPercentage
StatusBar1.Panels(1).Text = e.BytesReceived.ToString("0,0") & " from " & e.TotalBytesToReceive.ToString("0,0")
End Sub
Private Sub DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
ProgressBar1.Value = 0
If e.Cancelled Then
MessageBox.Show("Download was interrupted", "Download", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Else
MessageBox.Show("Download was successfull", "Download", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
'Download file from web.
Private Sub cmddownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddownload.Click
AddHandler myClient.DownloadFileCompleted, AddressOf Me.DownloadFileCompleted
AddHandler myClient.DownloadProgressChanged, AddressOf Me.DownloadProgressChanged
StatusBar1.Panels(0).Text = "Download"
Dim DR As DialogResult = FolderBrowserDialog1.ShowDialog
If DR = Windows.Forms.DialogResult.OK Then
myClient.DownloadFileAsync(New Uri(Web_Update.Downuri), _
FolderBrowserDialog1.SelectedPath.ToString & _
"\file.msi")
End If
'Me.Close()
'Application.Exit()
End Sub
End Class