BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.IO.TextReader

Implements a that reads characters from a byte stream in a particular encoding.

The class is designed for character input in a particular , whereas subclasses of are designed for byte input and output.

defaults to UTF-8 encoding unless specified otherwise, instead of defaulting to the ANSI code page for the current system. UTF-8 handles Unicode characters correctly and provides consistent results on localized versions of the operating system.

When reading from a , it is more efficient to use a buffer that is the same size as the internal buffer of the stream.

By default, a is not thread safe. For a thread-safe wrapper, see .

- Constructor
  The to read.

  Constructs and initializes a new instance of the class for the specified stream.

  This constructor initializes the property to , the property using , and the internal buffer to the default size. The default buffer size is implementation dependent.

  does not support reading.
  is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  A that specifies the complete file path to read.

  Constructs and initializes a new instance of the class for the specified file name.

  This constructor initializes the property to , and the internal buffer to the default size. The default buffer size is implementation defined.

  is not required to be a file stored on disk; it can be any part of a system that supports access via streams. For example, depending on the system, this class might be able to access a physical device.

  For information on the valid format and characters for path strings, see .

  is in an invalid format or contains invalid characters.
  The directory information specified in was not found.
  The file specified in was not found.
  is an empty string ("").
  is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  The to read.
  A value that indicates whether the new is required to look for byte order marks at the beginning of the stream. Specify to enable detection of byte order marks; otherwise, specify .

  Constructs and initializes a new instance of the class for the specified stream, with the specified byte order mark detection option.

  This constructor initializes the property to , the property using , and the internal buffer to the default size. The default buffer size is implementation defined.

  If requested, the current constructor detects the encoding by examining the first three bytes of the stream. The constructor automatically recognizes UTF-8, little-endian Unicode, and big-endian Unicode text if the file starts with the appropriate byte order marks. Otherwise, UTF-8 encoding is used. For more information, see the method.

  does not support reading.
  is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  The to read.
  A that specifies the character encoding to use.

  Constructs and initializes a new instance of the class for the specified stream with the specified character encoding.

  This constructor initializes the property using , the property using , and the internal buffer to the default size. The default buffer size is implementation defined.

  does not support reading.
  or is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  A that specifies the complete file path to read.
  A value that indicates whether the new is required to look for byte order marks at the beginning of the stream. Specify to enable detection of byte order marks; otherwise, specify .

  Constructs and initializes a new instance of the class for the specified file name, with the specified byte order mark detection option.

  This constructor initializes the property to , and the internal buffer to the default size. The default buffer size is implementation defined.

  If requested, the current constructor detects the encoding by examining the first three bytes of the stream. The constructor automatically recognizes UTF-8, little-endian Unicode, and big-endian Unicode text if the file starts with the appropriate byte order marks. Otherwise, UTF-8 encoding is used. See the method for more information.

  is not required to be a file stored on disk; it can be any part of a system that supports access via streams. For example, depending on the system, this class might be able to access a physical device.

  For information on the valid format and characters for path strings, see .

  is in an invalid format or contains invalid characters.
  The directory information specified in was not found.
  The file specified in was not found.
  is an empty string ("").
  is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  A that specifies the complete file path to read.
  A that specifies the character encoding to use.

  Constructs and initializes a new instance of the class for the specified file name and with the specified character encoding.

  This constructor initializes the property using , and the internal buffer to the default size. The default buffer size is implementation defined.

  is not required to be a file stored on disk; it can be any part of a system that supports access via streams. For example, depending on the system, this class might be able to access a physical device.

  For information on the valid format and characters for path strings, see .

  is in an invalid format or contains invalid characters.
  The directory information specified in was not found.
  The file specified in was not found.
  is an empty string ("").
  or is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  The to read.
  A that specifies the character encoding to use.
  A value that indicates whether the new is required to look for byte order marks at the beginning of the stream. Specify to enable detection of byte order marks; otherwise, specify .

  Constructs and initializes a new instance of the class for the specified stream, with the specified character encoding and byte order mark detection option.

  This constructor initializes the property using , the property using , and the internal buffer to the default size. The default buffer size is implementation defined.

  If requested, this constructor detects the encoding by examining the first three bytes of . This constructor automatically recognizes UTF-8, little-endian Unicode, and big-endian Unicode text if the stream starts with the appropriate byte order marks. Otherwise, the user-provided encoding is used. See the method for more information.

  does not support reading.
  or is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  A that specifies the complete file path to read.
  A that specifies the character encoding to use.
  A value that indicates whether the new is required to look for byte order marks at the beginning of the stream. Specify to enable detection of byte order marks; otherwise, specify .

  Constructs and initializes a new instance of the class for the specified file name, with the specified character encoding and byte order mark detection option.

  This constructor initializes the property using , and the internal buffer to the default size. The default buffer size is implementation defined.

  If requested, the current constructor detects the encoding by examining the first three bytes of the stream. The constructor automatically recognizes UTF-8, little-endian Unicode, and big-endian Unicode text if the file starts with the appropriate byte order marks. Otherwise, the user-provided encoding is used. See the

  method for more information.

  is not required to be a file stored on disk; it can be any part of a system that supports access via streams. For example, depending on the system, this class might be able to access a physical device.

  For information on the valid format and characters for path strings, see .

  is in an invalid format or contains invalid characters.
  The directory information specified in was not found.
  The file specified in was not found.
  is an empty string ("").
  or is .
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  The to read.
  A that specifies the character encoding to use.
  A value that indicates whether the new is required to look for byte order marks at the beginning of the stream. Specify to enable detection of byte order marks; otherwise, specify .
  A that specifies the minimum buffer size, in number of 16-bit characters. If is less than the minimum allowable size (128 characters), the minimum allowable size is used.

  Constructs and initializes a new instance of the class for the specified stream, with the specified character encoding, byte order mark detection option, and buffer size.

  This constructor initializes the property using parameter the property using .

  If requested, this constructor detects the encoding by examining the first three bytes of the stream. The constructor automatically recognizes UTF-8, little-endian Unicode, and big-endian Unicode text if the file starts with the appropriate byte order marks. Otherwise, the user-provided encoding is used. For more information, see the method.

  When reading from a , it is more efficient to use a buffer that is the same size as the internal buffer of the stream.

  does not support reading.
  or is .
  is less than or equal to zero.
  0
  1.0.5000.0
  2.0.0.0
- Constructor
  A that specifies the complete file path to read.
  A that specifies the character encoding to use.
  A value that indicates whether the new is required to look for byte order marks at the beginning of the stream. Specify to enable detection of byte order marks; otherwise, specify .
  A that specifies the minimum buffer size, in number of 16-bit characters. If less than the minimum allowable size (128 characters), the minimum allowable size is used.

  Constructs and initializes a new instance of the class for the specified file name, with the specified character encoding, byte order mark detection option, and buffer size.

  This constructor initializes the property using .

  If requested, the current constructor detects the encoding by examining the first three bytes of the stream. The constructor automatically recognizes UTF-8, little-endian Unicode, and big-endian Unicode text if the file starts with the appropriate byte order marks. Otherwise, the user-provided encoding is used. See the method for more information.

  is not required to be a file stored on disk; it can be any part of a system that supports access via streams. For example, depending on the system, this class might be able to access a physical device.

  When reading from a , it is more efficient to use a buffer that is the same size as the internal buffer of the stream.

  For information on the valid format and characters for path strings, see .

  is in an invalid format or contains invalid characters.
  The directory information specified in was not found.
  The file specified in was not found.
  is an empty string ("").
  or is .
  is less than or equal to zero.
  0
  1.0.5000.0
  2.0.0.0
- Property
  System.IO.Stream

  Gets the underlying stream.

  The underlying which the current instance is reading.

  This property is read-only.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Void

  Closes the current instance of , releasing any system resources associated with it.

  Following a call to this method, operations on the current instance might raise exceptions.

  This version of is equivalent to ().

  This method overrides .

  0
  1.0.5000.0
  2.0.0.0
- Property
  System.Text.Encoding

  Gets the current character encoding that the current is using.

  The current used by the current reader.

  This property is read-only.

  The value returned by this property might change after the first call to a method if encoding auto detection was specified to the constructor for the current instance.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Void

  Allows a to discard its buffered data.

  This method is useful when reading from a stream after seeking to a new position. If this method is not called and the internal buffer is not empty, a read attempt at the new location will first return data that is in the buffer before returning the text at the current position in the stream.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.Void `` to release both managed and unmanaged resources; to release only unmanaged resources.

  Releases the unmanaged resources used by the and optionally releases the managed resources.

  When the parameter is , this method releases all resources held by any managed objects that this references. This method invokes the method of each referenced object.

  can be called multiple times by other objects. When overriding (), be careful not to reference objects that have been previously disposed in an earlier call to .

  This method calls the dispose method of the base class, ().

  0
  1.0.5000.0
  2.0.0.0
- Property
  System.Boolean To be added. To be added. To be added. 2.0.0.0
- Field
  System.IO.StreamReader To be added. To be added. 1.0.5000.0 2.0.0.0
- Method
  System.Int32

  Returns the next character in the underlying stream without advancing the position of the in the stream.

  The next character from the character source as a , or -1 if at the end of the stream.

  This method returns -1 is when the end of the underlying stream is reached because a Unicode character can contain only values between hexadecimal 0x0000 to 0xFFFF (0 to 65535).

  This method overrides .

  An I/O error occurred. 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32

  Reads the next character from the input stream and advances the character position by one character.

  The next character from the character source represented as a , or -1 if at the end of the stream.

  This method returns -1 when the end of the underlying stream is reached because a Unicode character can contain only values between hexadecimal 0x0000 to 0xFFFF (0 to 65535).

  This method overrides .

  An I/O error occurred. 0 1.0.5000.0 2.0.0.0
- Method
  System.Int32 `` `` `` A array. When this method returns, contains the specified character array with the values between and replaced by the characters read from the current instance. A that specifies the index of at which to begin writing. A that specifies the maximum number of characters to read.

  Reads a maximum of characters from the current stream into , beginning at .

  A containing the number of characters that have been read, or zero if there are no more characters left to read. Can be less than if the end of the stream has been reached.

  This method returns after either characters are read, or the end of the file is reached. is a blocking version of .

  This method overrides .

  .Length - < . is . or is negative.

  An I/O error occurred.

  -or-

  The current stream is closed.

  0
  1.0.5000.0
  2.0.0.0
- Method
  System.String

  Reads a line of characters from the current stream and returns the data as a string.

  A containing the next line from the input stream, or if the end of the input stream is reached.

  This method defines a line as a sequence of characters followed by a carriage return (hexadecimal 0x000d), a line feed (hexadecimal 0x000a), or . The returned string does not contain the terminating character(s).

  This method overrides .

  An I/O error occurred. There is insufficient memory to allocate a buffer for the returned string. 0 1.0.5000.0 2.0.0.0
- Method
  System.String

  Reads the stream from the current position to the end of the stream.

  A containing the rest of the stream as a string, from the current position to the end. If the current position is at the end of the stream, returns the empty string ("").

  This method overrides .

  An I/O error occurred. There is insufficient memory to allocate a buffer for the returned string. 0 1.0.5000.0 2.0.0.0
0 System.Runtime.InteropServices.ComVisible(true)