How to find the length of a network stream which does not support

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a network stream which I got from HttpWebResponse and does not support
seeking, How do I find the length of the network stream?

HttpWebResponse* response = dynamic_cast<HttpWebResponse*>
(request->GetResponse());

// Gets the stream associated with the response.
Stream* receiveStream = response->GetResponseStream();

int n = receiveStream->Read(responseArray, 0, responseString->Length);
 
Sorry. Correct some typos.
-----------------------------------
I have a network stream which I got from HttpWebResponse and does not support
seeking, How do I find the length of the network stream?

HttpWebResponse* response = dynamic_cast<HttpWebResponse*>
(request->GetResponse());

// Gets the stream associated with the response.
Stream* receiveStream = response->GetResponseStream();

int n = receiveStream->Read(responseArray, 0, receiveStream->Length);
 
Kueishiong Tu said:
Sorry. Correct some typos.
-----------------------------------
I have a network stream which I got from HttpWebResponse and does not support
seeking, How do I find the length of the network stream?

HttpWebResponse* response = dynamic_cast<HttpWebResponse*>
(request->GetResponse());

// Gets the stream associated with the response.
Stream* receiveStream = response->GetResponseStream();

int n = receiveStream->Read(responseArray, 0, receiveStream->Length);

Well, you could use response.ContentLength - or you could just read the
whole stream (see http://www.pobox.com/~skeet/csharp/readbinary.html)
and then you'll know the length.
 
Back
Top