私のコードでは、Webサイトからファイルをダウンロードして、FolderBrowserDialogで選択したディレクトリに保存します。 ' Download the files If My.Computer.Network.IsAvailable Then Try wClient.DownloadFile(New Uri("DOWNLOAD LINK"), FolderBrowserDialog1.SelectedPath & "FILENAME.123") wClient.DownloadFile(New Uri("DOWNLOAD LINK"), FolderBrowserDialog1.SelectedPath & "FileName.123) wClient.DownloadFile(New Uri("Download LINK"), FolderBrowserDialog1.SelectedPath & "FileName.123") Catch ex As Exception MessageBox.Show(ex.Message) End Try
Webclient.DownloadFile to Folderbrowser.Selectedpath
0
A
答えて
0
私はあなたのために書いたサンプルコードを用意しています。 最初にwClient
とWebClient
をEvents
と宣言しているので、ファイルのダウンロード時に何が起きるかをトリガーすることができます。
VLC Media Playerを例としてダウンロードしましたが、ニーズに合わせて変更しました。注記これは、ボタンクリックイベントで行いました。
Imports System.ComponentModel
Imports System.Net
Public Class Form1
Private WithEvents wClient As New WebClient()
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim FolderBrowserDiaglog1 As New FolderBrowserDialog()
Dim folderPath As String = ""
Dim fileName As String = "vlc.exe"
Dim downloadFile As String = "https://get.videolan.org/vlc/2.2.6/win32/vlc-2.2.6-win32.exe" ''VLC MEDIA PLAYER
If FolderBrowserDiaglog1.ShowDialog() = DialogResult.OK Then
folderPath = FolderBrowserDiaglog1.SelectedPath
End If
If My.Computer.Network.IsAvailable Then
Dim combinePath As String = System.IO.Path.Combine(folderPath, fileName)
wClient.DownloadFileAsync(New Uri(downloadFile), combinePath)
End If
End Sub
Private Sub wClient_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles wClient.DownloadFileCompleted
MessageBox.Show("File Downloaded")
End Sub
End Class
はwClient
のイベントリストで見てくださいと、そのような私は、ファイルがダウンロードされた後、メッセージボックスを表示している作った一人としてavalibleている多くのオプションを参照してください。
Webクライアントイベントhttps://msdn.microsoft.com/en-us/library/system.net.webclient_events(v=vs.110).aspx
関連する問題
- 1. WebClient.DownloadFileとWebClient.DownloadData
- 2. WebClient.DownloadFileパスの問題
- 3. WebClient.DownloadFileファイルVB.NETに変換
- 4. ファイルにアクセスすることができません - WebClient.DownloadFile
- 5. WebClient.DownloadFile URIにHTML文字を含む404エラー?
- 6. BackgroundWorker内でWebclient.DownloadFileを取り消します。
- 7. PowerShellの$ webclient.DownloadFile()への引数の受け渡し
- 8. CGContextAddEllipseInRect to CGImageRef to CGImageMaskCreate to CGContextClipToMask
- 9. WebClient.DownloadFileを呼び出すとMatlabのログインとダウンロードに失敗する
- 10. c#webClient.DownloadFileはダウンロードされません。空のテキストファイルが作成されます。
- 11. webclient.downloadfileエラー403を解決する方法は禁止されています
- 12. Actionscript3 to LLVM to?
- 13. Facebook post to wall to work to work
- 14. HTML to> AJAX to>ノードto Arduino
- 15. View to Model to Settings
- 16. SendMessage to Notepad ++ to C#
- 17. Click to call to openVBX
- 18. UILabel to NSString to webview
- 19. xml to html to xml
- 20. .filter to array to array。
- 21. $ _POST to php to PHP
- 22. Python:Excel to Web to PDF
- 23. Java to JRuby to Resque
- 24. php to json to chart.js
- 25. how to byte [] to timestamp
- 26. node.js:youtube to mp4 to mp3
- 27. three.js to webGL to OpenGL
- 28. と[Db to PHP to JSON to AJAX to HTML]速度差
- 29. NIFI-Dev to Test to Prod
- 30. Android opencv byte [] to mat to byte []