|
-
Jan 7th, 2019, 12:52 PM
#1
Thread Starter
Member
[RESOLVED]Webclient downloader
Hi, whats wrong with this code? It doesnt work, because it doesnt download the file, only steps in the DownloadFileCompleted sub. Thank you!
Code:
Imports System.ComponentModel
Imports System.Net
Public Class Form2
Dim hely As String
Public WithEvents wc As System.Net.WebClient
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
wc = New System.Net.WebClient
FolderBrowserDialog1.ShowNewFolderButton = False
FolderBrowserDialog1.Description = "Kérlek válaszd ki a mappát ahova telepiteni szeretnéd!"
FolderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer
If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
hely = FolderBrowserDialog1.SelectedPath
Dim uri As Uri = New Uri("https://drive.google.com/uc?authuser=1&id=1N-ajoDD7VL4NyeRIsiETks2AqPpwbHbP&export=download")
wc.DownloadFileAsync(uri, My.Computer.FileSystem.SpecialDirectories.Temp & "\klienstemp\client.rar")
Else
Me.Hide()
Form1.Show()
End If
End Sub
Private Sub wc_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles wc.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
Label1.Text = "Méret: " & Int((e.BytesReceived / 1024) / 1024) & "/" & Int((e.TotalBytesToReceive / 1024) / 1024) & "Megabyte"
End Sub
Private Sub wc_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles wc.DownloadFileCompleted
Label1.Text = ""
MessageBox.Show("A letöltés befejeződött!", "Felhivás", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Sub
End Class
Last edited by Daveeed; Jan 8th, 2019 at 09:09 AM.
-
Jan 7th, 2019, 08:04 PM
#2
Frenzied Member
Re: Webclient downloader
I'm not sure. Maybe it the wc.downloadfileasync method? What if you change that to wc.downloadfile?
-
Jan 7th, 2019, 10:10 PM
#3
Re: Webclient downloader
You should be testing the e.Error property in the DownloadFileCompleted event handler to determine whether an exception was thrown and, if so, what it was.
-
Jan 8th, 2019, 04:33 AM
#4
Thread Starter
Member
Re: Webclient downloader
"An exception occured druing a Webclient request", maybe I'm using it to earlier, like the program hasnt started completely, or something?
-
Jan 8th, 2019, 04:46 AM
#5
Thread Starter
Member
Re: Webclient downloader
+ I tried with simple DownloadFile, and it gives me the same: An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: An exception occurred during a WebClient request.
-
Jan 8th, 2019, 06:28 AM
#6
Re: Webclient downloader
Look deeper into the exception. There's more information than that.
-
Jan 8th, 2019, 09:08 AM
#7
Thread Starter
Member
Re: Webclient downloader
Okay, finally I resolved it, thank you very much!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|