title: Advanced TextReader to EndOfFile
body: <p>I have a textReader that in a specific instance I want to be able to advance to the end of file quickly so other classes that might hold a reference to this object will not be able to call tr.ReadLine() without getting a null.</p>
  
  <p>This is a large file.  I cannot use TextReader.ReadToEnd() as it will often lead to an OutOfMemoryException</p>
  
  <p>I thought I would ask the community if there was a way SEEK the stream without using TextReader.ReadToEnd() which returns a string of all data in the file.</p>
  
  <p>Current method, inefficient.<br>
  The following example code is a mock up.  Obviously I am not opening a file with an if statement directly following it asking if I want to read to the end.</p>
  
  <pre><code>TextReader tr = new StreamReader("Largefile");
  if(needToAdvanceToEndOfFile)
  {
      while(tr.ReadLine() != null) { }
  }
  </code></pre>
  
  <p>Desired solution (Note this code block contains fake 'concept' methods or methods that cannot be used due to risk of outofmemoryexception)</p>
  
  <pre><code>TextReader tr = new StreamReader("Largefile");
  if(needToAdvanceToEndOfFile)
  {
      tr.SeekToEnd(); // A method that does not return anything. This method does not exist.
      // tr.ReadToEnd() not acceptable as it can lead to OutOfMemoryException error as it is very large file.
  }
  </code></pre>
  
  <p>A possible alternative is to read through the file in bigger chunks using                 tr.ReadBlock(args).  </p>
  
  <p>I poked around ((StreamReader)tr).BaseStream but could not find anything that worked.  </p>
  
  <p>As I am new to the community I figured I would see if someone knew the answer off the top of their head.</p>