本文整理汇总了VB.NET中System.IO.WindowsRuntimeStreamExtensions.AsOutputStream方法的典型用法代码示例。如果您正苦于以下问题:VB.NET WindowsRuntimeStreamExtensions.AsOutputStream方法的具体用法?VB.NET WindowsRuntimeStreamExtensions.AsOutputStream怎么用?VB.NET WindowsRuntimeStreamExtensions.AsOutputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.WindowsRuntimeStreamExtensions
的用法示例。
在下文中一共展示了WindowsRuntimeStreamExtensions.AsOutputStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: OnNavigatedTo
' 导入命名空间
Imports Windows.Storage.Streams
Public NotInheritable Class BlankPage
Inherits Page
Dim ue As System.Text.UnicodeEncoding
Dim bytesToWrite() As Byte
Dim bytesToAdd() As Byte
Dim totalBytes As Integer
Protected Overrides Sub OnNavigatedTo(e As Navigation.NavigationEventArgs)
ue = New System.Text.UnicodeEncoding()
bytesToWrite = ue.GetBytes("example text to write to memory stream")
bytesToAdd = ue.GetBytes("text added through datawriter")
totalBytes = bytesToWrite.Length + bytesToAdd.Length
End Sub
Private Async Sub CreateButton_Click(sender As Object, e As RoutedEventArgs)
Dim bytesRead(totalBytes - 1) As Byte
Using memStream As MemoryStream = New MemoryStream(totalBytes)
Await memStream.WriteAsync(bytesToWrite, 0, bytesToWrite.Length)
Dim writer As DataWriter = New DataWriter(memStream.AsOutputStream())
writer.WriteBytes(bytesToAdd)
Await writer.StoreAsync()
memStream.Seek(0, SeekOrigin.Begin)
Dim reader As DataReader = New DataReader(memStream.AsInputStream())
Await reader.LoadAsync(CType(totalBytes, UInteger))
reader.ReadBytes(bytesRead)
Results.Text = ue.GetString(bytesRead, 0, bytesRead.Length)
End Using
End Sub
End Class