私のコードでは、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. BackgroundWorker内でWebclient.DownloadFileを取り消します。
- 4. ファイルにアクセスすることができません - WebClient.DownloadFile
- 5. WebClient.DownloadFile URIにHTML文字を含む404エラー?
- 6. CGContextAddEllipseInRect to CGImageRef to CGImageMaskCreate to CGContextClipToMask
- 7. Actionscript3 to LLVM to?
- 8. webclient.downloadfileエラー403を解決する方法は禁止されています
- 9. WebClient.DownloadFileを呼び出すとMatlabのログインとダウンロードに失敗する
- 10. Facebook post to wall to work to work
- 11. xml to html to xml
- 12. Python:Excel to Web to PDF
- 13. Java to JRuby to Resque
- 14. SendMessage to Notepad ++ to C#
- 15. $ _POST to php to PHP
- 16. View to Model to Settings
- 17. node.js:youtube to mp4 to mp3
- 18. three.js to webGL to OpenGL
- 19. UILabel to NSString to webview
- 20. Click to call to openVBX
- 21. と[Db to PHP to JSON to AJAX to HTML]速度差
- 22. Linq to SQL - DateTime to Time
- 23. Image to Base64 String to JSONオブジェクト
- 24. Go To Toとは何か?
- 25. ruby on rail to users to timezone
- 26. Salesforce Apex SingleEmailMessage to Template to User
- 27. LINQ to SQLとLINQ to DataSet
- 28. Linq to SQL One To Many
- 29. NIFI-Dev to Test to Prod
- 30. LINQ to Entities to Interface Property