Visual Basic Downloader Pfad festlegen

1 Antwort

Hier ein Download-Beispiel mit einer ProgressBar und Fortschrittsanzeige. Du brauchst nur noch eine Form mit einer Progressbar und einem Label und einen Button.

Imports System.Net

Public Class Form1

    Private Sub btn_start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_start.Click
        Dim wc As New WebClient
        AddHandler wc.DownloadProgressChanged, AddressOf DownloadProgressChanged
        AddHandler wc.DownloadFileCompleted, AddressOf DownloadFileCompleted
        wc.DownloadFileAsync(New System.Uri("www.Adresse"), My.Application.Info.DirectoryPath & "/file.pdf")

    End Sub

    Public Sub DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
        progress_download.Value = e.ProgressPercentage
        lbl_Info.Text = e.BytesReceived & "/" & e.TotalBytesToReceive

    End Sub

    Public Sub DownloadFileCompleted(ByVal sender As Object, ByVal e As EventArgs)
        MessageBox.Show("Download fertig!", "Downloader", MessageBoxButtons.OK)

    End Sub

End Class
Woher ich das weiß:Berufserfahrung – Softwareentewickler / Unternehmensberater bei CSDIT iR

GamingLPlay 
Beitragsersteller
 18.02.2015, 13:26

Danke!

0