Home  |  Delphi .net Home  |  System.IO.BufferedStream  |  Close Method
Close  
Method  
Closes the BufferedStream
BufferedStream Class
System.IO NameSpace
NotCF1.  Procedure Close ( ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
Closes the BufferedStream stream, calling the Dispose method to do so.
 
After closing the stream, an exception will be thrown if you try to write to it again.
Microsoft MSDN Links
System.IO
System.IO.BufferedStream
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  Memory    : System.IO.MemoryStream;
  Stream    : System.IO.BufferedStream;
  ByteAsInt : Integer;

begin
  // Create our memory stream
  Memory := System.IO.MemoryStream.Create;

  // Create out BufferedStream to access this memory stream
  Stream := System.IO.BufferedStream.Create(Memory);

  // Read and write to the memory stream using the BufferedStream
  Stream.WriteByte(1);
  Stream.WriteByte(2);
  Stream.WriteByte(3);

  // Now seek to the start of the stream
  Stream.Seek(0, SeekOrigin.Begin);

  // Now display the contents
  ByteAsInt := Stream.ReadByte;

  while ByteAsInt > 0 do
  begin
    Console.WriteLine(ByteAsInt.ToString);
    ByteAsInt := Stream.ReadByte;
  end;

  // Close the stream
  Stream.Close;

  Console.Readline;
end.
Show full unit code
  1
  2
  3
 
 
Delphi Programming © Neil Moffatt All rights reserved.  |  Contact the author