[VB10] Downloader Source Code falsch. Hilfe

09/24/2012 18:05 ArcticShoot#1
Hallo :)

Ich wollte mir einen Downloader erstellen und als ich nun endlich fertig war kam diese Fehlermeldung Ungültiger URI: Der URI ist leer.

Hier ist die Source von dieser Fehlermeldung:

Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        download = New WebClient
        downloader.DownloadFileAsync(New Uri(TextBox1.Text), (TextBox2.Text))


        Me.Button1.Enabled = False
    End Sub
Was bedeutet das ?
09/24/2012 20:23 Kraizy​#2
Was steht denn in TextBox1?
09/24/2012 20:40 ArcticShoot#3
Hab Textboxen noch nicht. ^^

Hier nochmal der ganze Code

Code:
Imports System.Net

Public Class Form1

    Public WithEvents downloader As WebClient

    Private Property download As WebClient

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim Speichern = New FolderBrowserDialog
        Speichern.ShowDialog()
        Me.TextBox2.Text = Speichern.SelectedPath
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        download = New WebClient
        downloader.DownloadFileAsync(New Uri(TextBox1.Text), (TextBox2.Text))


        Me.Button1.Enabled = False
    End Sub

    Private Sub downloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles downloader.DownloadFileCompleted
        MsgBox("Der Download ist beendet!", MsgBoxStyle.Information, "Beendet")
        Me.ProgressBar1.Value = 0
        Me.Label3.Text = "0 von 0 Bytes"
        Me.Label4.Text = "0%"
        Me.Button1.Enabled = True
    End Sub

    Private Sub downloader_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloader.DownloadProgressChanged
        Me.ProgressBar1.Value = e.ProgressPercentage
        Me.Label3.Text = e.BytesReceived & "von" & e.TotalBytesToReceive & "Bytes"
        Me.Label4.Text = e.ProgressPercentage & "%"
    End Sub
End Class
09/24/2012 20:43 Kraizy​#4
Wie benutzt du dann "TextBox1.Text", wenn du angeblich noch keine TextBoxen hast..?
Und wieso hast du 1x download und 1x downloader? Räum mal deinen Code etwas auf...

PHP Code:
Private WithEvents downloader As New WebClient

Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
   downloader
.DownloadFileAsync(New Uri("http://www.bla.de/bla.exe"), "pfad.exe")
End Sub

Private Sub ProgressChanged(ByVal sender As ObjectByVal e As DownloadProgressChangedEventArgsHandles downloader.DownloadProgressChanged
   Debug
.Print(CStr(e.ProgressPercentage))
End Sub

Private Sub DownloadComplete(ByVal sender As ObjectByVal e As System.ComponentModel.AsyncCompletedEventArgsHandles downloader.DownloadFileCompleted
   MsgBox
("fertig")
End Sub 
09/28/2012 22:25 airsonic#5
vielleicht hat er den Code irgendwo gefunden :)
09/28/2012 22:44 ArcticShoot#6
Ne hab den Code nirgendwo gefunden :)

Hat sich geklärt!