简体   繁体   English

如何使用FolderBrowserDialog设置下载位置

[英]How to set download location with FolderBrowserDialog

I am trying to use FolderBrowserDialog to select the location where a file will be downloaded. 我正在尝试使用FolderBrowserDialog选择将下载文件的位置。 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? 我需要用什么替换“ C:\\ Users \\ Administrator”?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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