-
Mar 24th, 2013, 08:14 PM
#1
Thread Starter
Addicted Member
[RESOLVED] VB Downloader not working
What I want the program to do/What is happening.
How come this doesn't work??? I want the user to select one of the following items in a listbox and the direct link will appear in the DwlLocation textbox and then afterthat the user presses download and it asks where to save the file then the user inputs a file name and then if begins downloading with the progress bar in sync with actual progress. This worked for me individually then I sent it to my friend and it didn't work it would make a file with 0KB and its damaged. Then after I tryed and it didn't work for me as well! I really appreciate you for reading this!
Code:
Private Sub BtnDownload_Click(sender As System.Object, e As System.EventArgs) Handles BtnDownload.Click
If Lstavailable.SelectedItem = Nothing Then
MsgBox("Please choose a picture to download", MsgBoxStyle.Critical, "Error Selection")
Else
SaveFilePic.Filter = ".png|*.png"
SaveFilePic.Title = "Choose where to download it to!"
SaveFilePic.ShowDialog()
If SaveFilePic.FileName = Nothing Then
MsgBox("Please name your saved file or unable to complete request.", MsgBoxStyle.Critical)
TxtDwlSrc.Clear()
Else
TxtDwlLocation.Text = SaveFilePic.FileName
WebClient.DownloadFileAsync(New Uri(TxtDwlSrc.Text), TxtDwlLocation.Text)
Lstavailable.Enabled = False
End If
End If
End Sub
Private Sub WebClient1_DownloadFileCompleted(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs) Handles WebClient.DownloadFileCompleted
Dim selectPic As String
selectPic = LstMaps.SelectedItem
MsgBox(selectPic & " finished downloading!", MsgBoxStyle.Information, "Pictures")
End Sub
Private Sub WebClient1_DownloadProgressChanged(sender As Object, e As System.Net.DownloadProgressChangedEventArgs) Handles WebClient.DownloadProgressChanged
DwldProgress.Value = e.ProgressPercentage
Text = "download pictures" & " - " & e.ProgressPercentage.ToString + "%" & " Downloaded."
End Sub
Private Sub Lstavailable_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles Lstavailable.SelectedIndexChanged
If Lstavailable.SelectedItem = "Terminal" Then
TxtDwlSrc.Text = "the direct download link here" 'Keep in mind where I put "the direct download link here" its the direct link to the file.
ElseIf Lstavailable.SelectedItem = "Alle" Then
TxtDwlSrc.Text = "the direct download link here"
ElseIf Lstavailable.SelectedItem = "Mary" Then
MsgBox("the direct download link here")
TxtDwlSrc.Clear()
End If
End Sub
End Class
Changed event "WebClient1" to "WebClient" = Still Not Resolved.
Problem: Once I press download it says finished downloading and blank damaged file appears.
Last edited by Reapism; Mar 24th, 2013 at 08:35 PM.
-
Mar 24th, 2013, 08:29 PM
#2
Re: VB Downloader not working
WebClient.DownloadFileAsync(...), that method isn't shared, where do you create the WebClient object? In your events it looks like it's named WebClient1.
-
Mar 24th, 2013, 08:33 PM
#3
Thread Starter
Addicted Member
Re: VB Downloader not working
Oo, sorry about that.. I changed it and same result
-
Mar 24th, 2013, 09:19 PM
#4
Re: VB Downloader not working
You changed it to what? Where is it declared and created?
Last edited by Joacim Andersson; Mar 24th, 2013 at 09:32 PM.
-
Mar 24th, 2013, 09:26 PM
#5
Thread Starter
Addicted Member
Re: VB Downloader not working
Yes, the name of the webclient is webclient and declared in the code as well. could you try to recreate the code to work with any file? and link?
-
Mar 24th, 2013, 09:43 PM
#6
Re: VB Downloader not working
I don't know about any file but yes I have no problems downloading files. Do you use absolute URLs including http:// ?
-
Mar 24th, 2013, 10:09 PM
#7
Thread Starter
Addicted Member
Re: VB Downloader not working
I host the files on Google Crive. I just download the file.. when its done downloading in Google Chrome there's a option to copy link address and that's what I fill into the
TxtDwlSrc.Text = "the direct download link here"
This did work at one point but all the sudden it doesn't. It's a very weird process and I'm reaching out to people on here that may be aware of the issue.
Heres some of the link I am using although it is not the full link that is 1/3 of it. So I do use absolute or no? If so, how can I make it a absolute URL. Or a quick fix.
"https://doc-0g-1c-docs.googleusercontent.com/docs/securesc..."
Last edited by Reapism; Mar 24th, 2013 at 10:11 PM.
Reason: adding a bit of info.
-
Mar 24th, 2013, 11:49 PM
#8
Re: VB Downloader not working
Yes that URL uses an absolute path. Can you just paste the url into a webbrowser and see the image?
-
Mar 25th, 2013, 04:41 PM
#9
Thread Starter
Addicted Member
Re: VB Downloader not working
yea i can see the image . Is there a more expeditious way to write this task or any other way. Because this strangely doesn't work all the sudden.
-
Mar 26th, 2013, 04:03 PM
#10
Thread Starter
Addicted Member
Re: VB Downloader not working
Should I rewrite the application maybe theirs a hidden error. Okay I will do that and write back here.
-
Mar 27th, 2013, 03:24 PM
#11
Thread Starter
Addicted Member
Re: VB Downloader not working
Okay, I rewrote the entire program and used a Direct permalink instead. this seemed to solve the issue. For those who have trouble with this.
Use a direct Permalink to the file and it should be a absolute path.
-
Mar 27th, 2013, 03:40 PM
#12
Re: VB Downloader not working
Originally Posted by Reapism
and it should be a absolute path.
FYI: You can use a relative path as well if you've set the BaseAddress property of the WebClient.
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
|