hey, ich wollte ein Youtube Downloader machen.
Alles klappt soweit auser dass er downloadet.
PHP
Option Strict On
Imports System.Net
Public Class Form1
Public WithEvents download As WebClient
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
download = New WebClient
Dim URL As String = TextBox1.Text
Dim ZIEL As String = TextBox2.Text
ProgressBar1.Value = 0
Try
download.DownloadFileAsync(New Uri(TextBox1.Text), ZIEL & Namenberechnen(URL))
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Function Namenberechnen(ByVal url As String) As String
Dim name As String = Nothing
Dim stelle As Integer = url.LastIndexOf("/")
name = Mid(url, (stelle) + 1)
Return name
End Function
Private Sub download_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles download.DownloadFileCompleted
MsgBox("Download abgeschlossen!", MsgBoxStyle.Information)
End Sub
Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
Dim totalbytes As Long = CLng(e.TotalBytesToReceive / 1024)
Dim bytes As Long = CLng(e.BytesReceived / 1024)
Label3.Text = CStr(bytes) & " % von " & CStr(totalbytes) & "%"
End Sub
Private Sub TextBox2_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox2.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim folder As New FolderBrowserDialog
If folder.ShowDialog = Windows.Forms.DialogResult.OK Then
TextBox2.Text = folder.SelectedPath & "\"
End If
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
Alles anzeigen