Results 1 to 12 of 12

Thread: [RESOLVED] VB Downloader not working

  1. #1

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Resolved [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.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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.

  3. #3

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: VB Downloader not working

    Oo, sorry about that.. I changed it and same result

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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.

  5. #5

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    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?

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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:// ?

  7. #7

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    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.

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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?

  9. #9

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    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.

  10. #10

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    Re: VB Downloader not working

    Should I rewrite the application maybe theirs a hidden error. Okay I will do that and write back here.

  11. #11

    Thread Starter
    Addicted Member Reapism's Avatar
    Join Date
    Sep 2012
    Posts
    170

    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.

  12. #12
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: VB Downloader not working

    Quote Originally Posted by Reapism View Post
    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
  •  



Click Here to Expand Forum to Full Width