DelphiBasics
  Home  |  Delphi .net Home  |  System.IO NameSpace
 .NET Framework
 Namespace References

 System
 System.Collections
 System.Globalization
 System.IO
 
  BinaryReader  Class 
  BinaryWriter  Class 
  BufferedStream  Class 
  Directory  Class 
  DirectoryInfo  Class 
  File  Class 
  FileAccess  Enumeration 
  FileAttributes  Enumeration 
  FileInfo  Class 
  FileMode  Enumeration 
  FileShare  Enumeration 
  FileStream  Class 
  FileSystemWatcher  Class 
  MemoryStream  Class 
  Path  Class 
  SeekOrigin  Enumeration 
  StreamReader  Class 
  StreamWriter  Class 
  StringReader  Class 
  StringWriter  Class 

 Articles and Tutorials

 Overview of .NET
 Delphi and .NET
 Winform Applications
 ASP .Net Applications
 php Web Services
 Framework Collections
 Framework String Handling
 Framework Files and Folders


 
 
  System.IO.BinaryReader Class
 
 Description
This class is used to read from a stream containing primitive data in binary (rather than character). This stream is sourced from a file, as in the examples.
 
There are discrete methods for reading individual primitive data type values, such as Bytes and Singles. You must catch the EndOfStreamException when using these discrete data types.
 
For the generic Read method, -1 is returned if the end of stream was encountered. For the array syntax Read methods, a count of 0 will be returned when the end of stream is encountered.
 
When reading from a Binary file, it is crucial that the formatting of data used by BinaryWriter be accurately recognised. Being 1 byte out of sequence can completely destroy the sequencing of the remaining file contents.
 Syntax
Constructor Create ( DataStream : System.IO.Stream ; );
Constructor Create ( DataStream : System.IO.Stream; DataEncoding : System.Text.Encoding );
 Methods
Close  Closes the BinaryReader
PeekChar  Returns (peeks at) the next stream byte without updating stream position
Read  Reads the next character or block of characters from the current stream
ReadBoolean  Reads the next byte from the current stream as a Boolean
ReadByte  Reads the next byte from the current stream
ReadBytes  Reads the next block of bytes from the current stream
ReadChar  Reads the next character from the current stream
ReadChars  Reads the next block of characters from the current stream
ReadDecimal  Reads the next 16 bytes from the current stream as a Decimal number
ReadInt16  Reads the next 2 bytes from the current stream as an Int16 number
ReadInt32  Reads the next 4 bytes from the current stream as an Int32 number
ReadInt64  Reads the next 8 bytes from the current stream as an Int64 number
ReadSByte  Reads the next signed byte from the current stream
ReadSingle  Reads the next 16 bytes from the current stream as a Single number
ReadString  Reads a string from the current stream
ReadUInt16  Reads the next 2 bytes from the current stream as an UInt16 number
ReadUInt32  Reads the next 4 bytes from the current stream as an UInt32 number
ReadUInt64  Reads the next 8 bytes from the current stream as an UInt64 number

 Properties
BaseStream  Stream  Exposes access to the underlying stream of the BinaryReader

 Microsoft MSDN links
 
System.IO
System.IO.binaryreader
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page