VB.Net by API/System.Net/WebClient — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:49, 26 мая 2010

WebClient.DownloadData

  
Imports System.Net
Imports System.IO
Imports System.Text

Public Class Tester
    Public Shared Sub Main
        Dim myWebClient As New WebClient()
        Dim mybyte() As Byte
        mybyte = myWebClient.DownloadData("http://www.vbex.ru")
        myWebClient.DownloadFile("http://www.vbex.ru", "test.txt")

    End Sub
End Class


WebClient.DownloadFile

  
Imports System.Net
Imports System.IO
Imports System.Text

Public Class Tester
    Public Shared Sub Main
        Dim myWebClient As New WebClient()
        Dim mybyte() As Byte
        mybyte = myWebClient.DownloadData("http://www.vbex.ru")
        myWebClient.DownloadFile("http://www.vbex.ru", "test.txt")

    End Sub
End Class


WebClient.OpenRead

  
Imports System.Net
Imports System.IO
Imports System.Text

Public Class Tester
    Public Shared Sub Main
        Dim myWebClient As New WebClient()
        Dim myStream As Stream
        Dim myByte() As Byte
        Try
            myWebClient = New WebClient()
            myStream = myWebClient.OpenRead("http://www.vbex.ru")
            Dim myStreamReader As New StreamReader(myStream)
            Console.WriteLine(myStreamReader.ReadToEnd)
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Sub
End Class