C# StreamReader StreamReader(String, Encoding)

Description

StreamReader StreamReader(String, Encoding) Initializes a new instance of the StreamReader class for the specified file name, with the specified character encoding.

Syntax

StreamReader.StreamReader(String, Encoding) has the following syntax.


public StreamReader(
  string path,
  Encoding encoding
)

Parameters

StreamReader.StreamReader(String, Encoding) has the following parameters.

  • path - The complete file path to be read.
  • encoding - The character encoding to use.

Example


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




















Home »
  C# Tutorial »
    System.IO »




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