New MemoryStream : MemortStream « System.IO « VB.Net by API






New MemoryStream

   


Imports System.IO
Imports System.Text
Imports System.Threading
        
Public Class Tester
    Public Shared Sub Main
        Dim bteRead() As Byte
        Dim bteArray(256) As Byte
        Dim myMemortStream As MemoryStream
        Dim myFileStream As FileStream
        Try
            myFileStream = New FileStream("test.vb", FileMode.Open, FileAccess.Read)
            ReDim bteRead(myFileStream.Length)
            myFileStream.Read(bteRead, 0, myFileStream.Length)
            myMemortStream = New MemoryStream(256)
            myMemortStream.Write(bteRead, 128, 256)

            bteArray = myMemortStream.ToArray()
            Console.WriteLine(Encoding.ASCII.GetString(bteArray))
            myMemortStream.Close()
            myFileStream.Close()
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End Sub

    
End Class
        

   
    
    
  








Related examples in the same category

1.MemortStream.Seek
2.MemortStream.ToArray()
3.MemortStream.Write
4.MemoryStream.Read