简体   繁体   中英

How to set download location with FolderBrowserDialog

I am trying to use FolderBrowserDialog to select the location where a file will be downloaded. This is the code for selecting a folder.

Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
    If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
        TextBox1.Text = FolderBrowserDialog1.SelectedPath
    End If
End Sub

Now I just need to know how to take directory that appears in the textbox and have the file get downloaded to there. Here is the code for the download.

My.Computer.Network.DownloadFile("http://download1516.mediafire.com/wtzr4h1b37zg/ptzcffq933e87c8/sword_custom.png", "C:\Users\Administrator")

What would I need to replace "C:\\Users\\Administrator" with?

Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
    Dim URL As String = "http://download1516.mediafire.com/wtzr4h1b37zg/ptzcffq933e87c8/sword_custom.png"
    Dim SaveFile As String = "sword_custom.png"

    With FolderBrowserDialog1
        If .ShowDialog = DialogResult.OK Then
            TextBox1.Text = .SelectedPath
            My.Computer.Network.DownloadFile(URL, IO.Path.Combine(.SelectedPath, SaveFile))
        End If
    End With
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM