title: How to set a timeout for a StreamReader operation that reads a file?
body: <p>How to set a timeout for a StreamReader operation that reads a file?</p>
  
  <p>I tried the accepted answer <a href="https://stackoverflow.com/questions/17215966/c-sharp-stream-read-with-timeout">here</a> but I'm getting the exception: "Timeouts are not supported on this stream."</p>
  
  <p>This is the sample code:</p>
  
  <pre><code>using System.IO;
  
  ...
  
  using (StreamReader reader = new StreamReader(@"C:\test.txt"))
  {
      reader.BaseStream.ReadTimeout = 1;
      string result = reader.ReadToEnd();
      reader.Close();                
  }
  </code></pre>
  
  <p>Thanks in advance.            </p>