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

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);
 
G

Guest

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);
 
J

Jon Skeet [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top