本文整理汇总了VB.NET中System.Net.WebClient类的典型用法代码示例。如果您正苦于以下问题:VB.NET WebClient类的具体用法?VB.NET WebClient怎么用?VB.NET WebClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WebClient类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Test
' 导入命名空间
Imports System.Net
Imports System.IO
Public Class Test
Public Shared Sub Main(args() As String)
If args Is Nothing OrElse args.Length = 0 Then
Throw New ApplicationException("Specify the URI of the resource to retrieve.")
End If
Dim client As New WebClient()
' Add a user agent header in case the
' requested URI contains a query.
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
Dim data As Stream = client.OpenRead(args(0))
Dim reader As New StreamReader(data)
Dim s As String = reader.ReadToEnd()
Console.WriteLine(s)
data.Close()
reader.Close()
End Sub
End Class