Hello,
I am creating a file downloader in Visual Basic 2012.
It works well, but when I click the red X button, it closes whether the download has finished or not. Thus,
I am looking for code that disables the X button at a certain time. I mean, I do not want it always disabled,
just when a file is being downloaded.
What is more, I am also looking for a code for creating
a Cancel button (to cancel file download).
Here's the file download code:
Grateful for any reply. Thank in advance
I am creating a file downloader in Visual Basic 2012.
It works well, but when I click the red X button, it closes whether the download has finished or not. Thus,
I am looking for code that disables the X button at a certain time. I mean, I do not want it always disabled,
just when a file is being downloaded.
What is more, I am also looking for a code for creating
a Cancel button (to cancel file download).
Here's the file download code:
Code:
Imports System.Net
Private WithEvents httpclient As WebClient
Private Sub DownloadButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadButton.Click
httpclient = New WebClient
Dim sourceURL = TextBox1.Text
Dim filedir = TextBox2.Text
ProgressBar1.Value = 0
ProgressBar1.Maximum = 100
Try
httpclient.DownloadFileAsync(New Uri(sourceURL), (filedir))
Catch ex As Exception
MessageBox.Show("Error while downloding", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Grateful for any reply. Thank in advance