System.IO.StreamReader.DiscardBufferedData Method

Clears the internal buffer.

Syntax

public void DiscardBufferedData ()

Remarks

Use the StreamReader.DiscardBufferedData method to reset the internal buffer for the System.IO.StreamReader object. You need to call this method only when the position of the internal buffer and the StreamReader.BaseStream do not match. These positions can become mismatched when you read data into the buffer and then seek a new position in the underlying stream. This method slows performance and should be used only when absolutely necessary, such as when you want to read a portion of the contents of a System.IO.StreamReader object more than once.

For a list of common I/O tasks, see Common I/O Tasks.

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0