MemoryStream Class creates a stream whose backing store is memory. : Memory Stream « File Directory « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » File Directory » Memory StreamScreenshots 
MemoryStream Class creates a stream whose backing store is memory.
 

Imports System
Imports System.IO
Imports System.Text

Module MemStream
    Sub Main()
        Dim count As Integer
        Dim byteArray As Byte()
        Dim charArray As Char()
        Dim uniEncoding As New UnicodeEncoding()

        Dim firstString As Byte() = uniEncoding.GetBytes("this is a test: ")
        Dim secondString As Byte() = uniEncoding.GetBytes("this is another test")

        Dim memStream As New MemoryStream(100)
        Try
            memStream.Write(firstString, , firstString.Length)
            count = 0
            While(count < secondString.Length)
                memStream.WriteByte(secondString(count))
                count += 1
            End While
            memStream.Seek(0, SeekOrigin.Begin)
            byteArray = New Byte(CType(memStream.Length, Integer)){}
            count = memStream.Read(byteArray, 020)

            While(count < memStream.Length)
                byteArray(count= Convert.ToByte(memStream.ReadByte())
                count += 1
            End While

            charArray = New Char(uniEncoding.GetCharCount(byteArray, 0, count)){}
            uniEncoding.GetDecoder().GetChars(byteArray, 0, count, charArray, 0)
            Console.WriteLine(charArray)
        Finally
            memStream.Close()
        End Try

    End Sub
End Module

   
  
Related examples in the same category
1.Memory Stream Writer and ReaderMemory Stream Writer and Reader
2.Stream Reader and Writer for a MemoryStreamStream Reader and Writer for a MemoryStream
3.MemoryStream DemoMemoryStream Demo
w_ww.j___a__v_a__2s.__c_o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.