Imports System.Net
Imports System.Text
Public Class Form1
Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click
Dim wc As New WebClient
Dim result() As Byte = Nothing
Dim str As String
Try
result = wc.DownloadData("")
str = Encoding.UTF8.GetString(result)
Dim pause As String = ""
Catch ex As Exception
End Try
End Sub
Private Sub btn_async_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_async.Click
Dim url As String = ""
Dim wc As New WebClient
AddHandler wc.DownloadDataCompleted, AddressOf DownloadDataCompleted
wc.DownloadDataAsync(New Uri(url))
End Sub
Private Shared Sub DownloadDataCompleted(ByVal sender As Object, ByVal e As DownloadDataCompletedEventArgs)
Dim str As String
Dim raw() As Byte = e.Result
str = Encoding.UTF8.GetString(raw)
Dim pause As String = ""
End Sub
End Class
' https://stackoverflow.com/questions/2375896/vb-net-downloaddataasync
' https://stackoverflow.com/questions/1585985/how-to-use-the-webclient-downloaddataasync-method-in-this-context
' https://stackoverflow.com/questions/35056500/download-file-from-google-drive-using-c-sharp-without-google-api
' https://stackoverflow.com/questions/19686599/download-file-directly-to-memory
No hay comentarios.:
Publicar un comentario