如何使用 FolderBrowserDialog 设置下载位置 [英] How to set download location with FolderBrowserDialog

查看:33
本文介绍了如何使用 FolderBrowserDialog 设置下载位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 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")

我需要用什么来替换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

这篇关于如何使用 FolderBrowserDialog 设置下载位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆