C# StreamReader DiscardBufferedData

Description

StreamReader DiscardBufferedData Clears the internal buffer.

Syntax

StreamReader.DiscardBufferedData has the following syntax.


public void DiscardBufferedData()

Returns

StreamReader.DiscardBufferedData method returns

Example


The following example shows how to use the DiscardBufferedData method. 

//from  w ww .ja va2 s . c  o  m
using System;
using System.IO;

class Test
{
    public static void Main()
    {
        string path = @"c:\temp\alphabet.txt";

        using (StreamReader sr = new StreamReader(path))
        {
            char[] c = null;
            c = new char[15];
            sr.Read(c, 0, c.Length);

            sr.DiscardBufferedData();
            sr.BaseStream.Seek(2, SeekOrigin.Begin);
 
            Console.WriteLine(sr.ReadToEnd());
        }
    }
}




















Home »
  C# Tutorial »
    System.IO »




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