C# BinaryReader BinaryReader(Stream, Encoding, Boolean)

Description

BinaryReader BinaryReader(Stream, Encoding, Boolean) Initializes a new instance of the BinaryReader class based on the specified stream and character encoding, and optionally leaves the stream open.

Syntax

BinaryReader.BinaryReader(Stream, Encoding, Boolean) has the following syntax.


public BinaryReader(
  Stream input,/*from  ww w. j  a v a  2s .c  o m*/
  Encoding encoding,
  bool leaveOpen
)

Parameters

BinaryReader.BinaryReader(Stream, Encoding, Boolean) has the following parameters.

  • input - The input stream.
  • encoding - The character encoding to use.
  • leaveOpen - true to leave the stream open after the BinaryReader object is disposed; otherwise, false.

Example


using System;/*from  ww  w .  j  a  v  a2s  .co m*/
using System.IO;
public class MainClass{
  public static void Main(String[] argv){  
    StreamReader sr = new StreamReader(new StreamReader("C:\\Temp\\Test.txt"),System.Text.Encoding.ASCII,false);
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter