title: StreamReader, C#, peek
body: <p>I have a StreamReader that once in a while check if it has more to read from a simple text file. It uses peek property. The problem is that when I am using peek the position is changed, althougth not suppose to.</p>
  
  <pre><code>FileStream m_fsReader = new FileStream(
                          m_strDataFileName,
                          FileMode.OpenOrCreate,
                          FileAccess.Read,
                          FileShare.ReadWrite                        );
  
  StreamReader m_SR = new StreamReader(m_fsReader);
  
  Console.WriteLine("IfCanRead SR Position " + m_fsReader.Position +
       " and Length " + m_fsReader.Length);
  
  if (m_SR.Peek() == -1) {
         Console.WriteLine("IfCanRead false 2 SR Position " + 
               m_fsReader.Position  + " and Length " + m_fsReader.Length);
  
         return false;
  }
  else {
         Console.WriteLine("IfCanRead true 2 SR Position " + 
             m_fsReader.Position + " and Length " + m_fsReader.Length);
  
         return true;
  }  
  </code></pre>