Imports system.net
Public Class Form1
Private Sub cmdsave_Click(sender As Object, e As EventArgs) Handles cmdsave.Click
SaveFileDialog.Filter = "All files (*.*)|*.*"
''"EXE (*.exe) |*.exe |JPEG (*.jpg)|*.jpg | MP3 (*.mp3)|*.mp3 | WAV (*.wav) |*.wav ";
SaveFileDialog.ShowDialog()
TextBox2.Text = SaveFileDialog.FileName
End Sub
Public WithEvents download As WebClient
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
download = New WebClient
download.DownloadFileAsync(New Uri(TextBox1.Text), TextBox2.Text)
End Sub
Private Sub download_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub
End Class
我正在尝试创建一个下载器但是我一直在使用SaveFileDialog区域出错。我是VB.Net的新手,我想知道我需要改变什么来使其工作并成功下载所有类型的文件。
答案 0 :(得分:0)
除非您已将SaveFileDialog声明为SaveFileDialog,否则我认为您的错误与非共享成员有关。这不会导致您的错误。
一条建议check this out表示删除网络客户端并将其读入您的表单。
另外,一个快速(脏?)修复是在您的应用程序属性下定位较低版本的.Net Framework。
其中任何一个都应该解决这个问题。