當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET FileWebRequest.GetRequestStream方法代碼示例

本文整理匯總了VB.NET中System.Net.FileWebRequest.GetRequestStream方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET FileWebRequest.GetRequestStream方法的具體用法?VB.NET FileWebRequest.GetRequestStream怎麽用?VB.NET FileWebRequest.GetRequestStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Net.FileWebRequest的用法示例。


在下文中一共展示了FileWebRequest.GetRequestStream方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: Byte

' Enter the string to write to the file.
Console.WriteLine("Enter the string you want to write:")
Dim userInput As String = Console.ReadLine()

' Convert the string to a byte array.
Dim encoder As New ASCIIEncoding
Dim byteArray As Byte() = encoder.GetBytes(userInput)

' Set the ContentLength property.
myFileWebRequest.ContentLength = byteArray.Length

Dim contentLength As String = myFileWebRequest.ContentLength.ToString()

Console.WriteLine(ControlChars.Lf + "The content length is {0}.", contentLength)


' Get the file stream handler to write to the file.
Dim readStream As Stream = myFileWebRequest.GetRequestStream()

' Write to the stream. 
' Note. For this to work the file must be accessible
' on the network. This can be accomplished by setting the property
' sharing of the folder containg the file.  
' FileWebRequest.Credentials property cannot be used for this purpose.
readStream.Write(byteArray, 0, userInput.Length)


Console.WriteLine(ControlChars.Lf + "The String you entered was successfully written to the file.")
開發者ID:VB.NET開發者,項目名稱:System.Net,代碼行數:28,代碼來源:FileWebRequest.GetRequestStream


注:本文中的System.Net.FileWebRequest.GetRequestStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。