How to set a timeout for a StreamReader operation that reads a file?
I tried the accepted answer here but I'm getting the exception: "Timeouts are not supported on this stream."
This is the sample code:
using System.IO;
...
using (StreamReader reader = new StreamReader(@"C:\test.txt"))
{
reader.BaseStream.ReadTimeout = 1;
string result = reader.ReadToEnd();
reader.Close();
}
Thanks in advance.