Mega Code Archive

 
Categories / VB.Net / File Directory
 

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