Srinivas M

Srinivas M

  • 1.3k
  • 435
  • 29k

How to perform Seek operation on a ConnectStream.

Mar 1 2019 1:05 AM
This is my code below shown.Actually, I'm trying to read data from streamreader in the middle due to network problem getting exception message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
 
To resume that stream, during data insertion into db at the same time inserting line count in to table. A fter problem occured then get the line count value form the db and try to perform seek operation on that stream but getting below exception.
 
this stream does not support seek operations
 
Please resolve it, if anyone get solved appreciated.
 
HttpWebResponse res = (HttpWebResponse)httpRequest.GetResponse();
Stream stream = res.GetResponseStream();
using (StreamReader sr = new StreamReader(stream))
{
string line = sr.ReadLine();
sr.BaseStream.Seek(8378, SeekOrigin.Begin);
}
//8378 line count inserted in db

Answers (1)