本文整理匯總了VB.NET中System.Net.WebClient.OpenWrite方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET WebClient.OpenWrite方法的具體用法?VB.NET WebClient.OpenWrite怎麽用?VB.NET WebClient.OpenWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Net.WebClient
的用法示例。
在下文中一共展示了WebClient.OpenWrite方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Byte
Dim uriString As String
Console.Write(ControlChars.Cr + "Please enter the URI to post data to : ")
uriString = Console.ReadLine()
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the URI {0}:", uriString)
Dim postData As String = Console.ReadLine()
' Apply ASCII Encoding to obtain an array of bytes .
Dim postArray As Byte() = Encoding.ASCII.GetBytes(postData)
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
Console.WriteLine("Uploading to {0} ...", uriString)
' OpenWrite implicitly sets HTTP POST as the request method.
Dim postStream As Stream = myWebClient.OpenWrite(uriString)
postStream.Write(postArray, 0, postArray.Length)
' Close the stream and release resources.
postStream.Close()
Console.WriteLine(ControlChars.Cr + "Successfully posted the data.")
示例2: Byte
Dim uriString As String
Console.Write(ControlChars.Cr + "Please enter the URI to post data to : ")
uriString = Console.ReadLine()
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the URI {0}:", uriString)
Dim postData As String = Console.ReadLine()
' Apply ASCII encoding to obtain an array of bytes.
Dim postArray As Byte() = Encoding.ASCII.GetBytes(postData)
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
Console.WriteLine("Uploading to {0} ...", uriString)
Dim postStream As Stream = myWebClient.OpenWrite(uriString, "POST")
postStream.Write(postArray, 0, postArray.Length)
' Close the stream and release resources.
postStream.Close()
Console.WriteLine(ControlChars.Cr + "Successfully posted the data.")