webbrowser download location?

ud2008

Well-known member
Joined
Jul 5, 2010
Messages
148
Programming Experience
Beginner
I have some code that makes it possible to download/convert a youtube movie (through a website) to mp3, it shows the download screen, but the location I want to be a specific location.

Here is the code I use, hope some one can help me:
VB.NET:
Private Sub ButtonX2_Click(sender As System.Object, e As System.EventArgs) Handles ButtonX2.Click
        If My.Computer.Network.IsAvailable Then
            Dim tempstring As String = TextBoxX1.Text
            Dim text1 As String = tempstring.Split("=")(0)
            Dim text2 As String = tempstring.Split("&")(0)
            Dim text3 As String = text2.Split("=")(1)
            WebBrowser1.Navigate("http://www.youtube-mp3.org/get?video_id=" + text3)
        Else
            MessageBox.Show("Make sure you have an active internet connection!")
        End If
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Dim s As String = WebBrowser1.Document.GetElementById("dl_link").InnerHtml
        If InStr(s, "<B>Downloaden</B>") Then
            Try
                Dim redirect As String = s.Replace("<A href=""", "").Replace("""><B>Downloaden</B></A> · <A onclick=""showLinkBox(); return false;"" href=""http://www.youtube-mp3.org/nl#"">Link deze mp3</A>", "")
                WebBrowser1.Navigate(redirect)
            Catch ex As Exception
                WebBrowser1.Stop()
                MsgBox("Unable to process your request, try again after a while.", vbCritical, "Error")
            End Try
        End If
    End Sub

Thanks.
 
Well the easiest way would be to wait for the download to finish and then move the file from the default location to your preferred one.

My.Computer.FileSystem.MoveFile(sourcename, targetname)
 
Back
Top