Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27216

VS 2010 VB Downloader not working

$
0
0
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.

Viewing all articles
Browse latest Browse all 27216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>