Stream.CopyTo Method reads all the bytes from the current stream and writes them to the destination stream. : Stream « File Directory « VB.Net






Stream.CopyTo Method reads all the bytes from the current stream and writes them to the destination stream.

 

Imports System
Imports System.IO

Class TestRW    

    Public Shared Sub Main()
        Dim destination As New MemoryStream()
        
        Using source As FileStream = File.Open("c:\temp\data.dat", _
                                               FileMode.Open)
            Console.WriteLine("Source length: {0}", source.Length.ToString())
            source.CopyTo(destination)
        
        End Using
        Console.WriteLine("Destination length: {0}", destination.Length.ToString())
    End Sub
End Class

   
  








Related examples in the same category

1.Stream.CanRead Property tells whether the current stream supports reading.
2.Stream.CanWrite Property tells whether the current stream supports writing.
3.Reads a maximum of count characters from the current stream into buffer
4.Stream.Read Method reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
5.Open a stream as ASCII
6.GZipStream Class
7.Compress streams
8.Decompress streams.
9.Stream.CanWrite Property tells whether the current stream supports writing.