就这么简单,我如何在VBNET 中将UnmanagedMemoryStream转换为Byte-Array?:
Dim bytes() As Byte = My.Resources.AudioFile
例外:
Value of type 'System.IO.UnmanagedMemoryStream' cannot be converted to '1-dimensional array of Byte'.
就这么简单,我如何在VBNET 中将UnmanagedMemoryStream转换为Byte-Array?:
Dim bytes() As Byte = My.Resources.AudioFile
例外:
Value of type 'System.IO.UnmanagedMemoryStream' cannot be converted to '1-dimensional array of Byte'.
您可以使用以下方法System.IO.MemoryStream
直接转换为Byte()
数组:
Dim myMemStream As New System.IO.MemoryStream
My.Resources.AudioFile.CopyTo(myMemStream)
Dim myBytes() As Byte = myMemStream.ToArray
试试这个方法。我尚未对其进行验证,但它遵循与 MSDN 中的文章类似的内容,并进行了一些修改。http://msdn.microsoft.com/en-us/library/system.io.unmanagedmemorystream.aspx
Dim audioBytes() as Byte
Dim audioStreamReader As System.IO.UnmanagedMemoryStream = CType(My.Resources.AudioFile, System.IO.UnmanagedMemoryStream)
Dim length As Long = audioStreamReader.Length
audioStreamReader.Position = 0
audioStreamReader.Read(bytes, 0, length);
'At this point, audioBytes contains the data.