title: c# - StreamReader and seeking
body: <p>Can you use <code>StreamReader</code> to read a normal textfile and then in the middle of reading close the <code>StreamReader</code> after saving the current position and then open <code>StreamReader</code> again and start reading from that poistion ?</p>
  <p>If not what else can I use to accomplish the same case without locking the file ?</p>
  <p>I tried this but it doesn't work:</p>
  <pre class="lang-cs prettyprint-override"><code>var fs = File.Open(@ &quot;C:\testfile.txt&quot;, FileMode.Open, FileAccess.Read);
  var sr = new StreamReader(fs);
  
  Debug.WriteLine(sr.ReadLine()); //Prints:firstline
  
  var pos = fs.Position;
  
  while (!sr.EndOfStream) 
  {
      Debug.WriteLine(sr.ReadLine());
  }
  
  fs.Seek(pos, SeekOrigin.Begin);
  
  Debug.WriteLine(sr.ReadLine());
  //Prints Nothing, i expect it to print SecondLine.
  </code></pre>
  <hr />
  <p>Here is the other code I also tried :</p>
  <pre class="lang-cs prettyprint-override"><code>var position = -1;
  StreamReaderSE sr = new StreamReaderSE(@ &quot;c:\testfile.txt&quot;);
  
  Debug.WriteLine(sr.ReadLine());
  position = sr.BytesRead;
  
  Debug.WriteLine(sr.ReadLine());
  Debug.WriteLine(sr.ReadLine());
  Debug.WriteLine(sr.ReadLine());
  Debug.WriteLine(sr.ReadLine());
  
  Debug.WriteLine(&quot;Wait&quot;);
  
  sr.BaseStream.Seek(position, SeekOrigin.Begin);
  Debug.WriteLine(sr.ReadLine());
  </code></pre>