I need to read a stream in this way:
using(HttpWebResponse response = (HttpWebResponse)request.getResponse())
{
using(Stream answer = response.getResponseStream())
{
// waiting for a while to read next
}
}
However, I don't know the stream length. According Fiddler the stream length is greater than 15,000,000 bytes.
Is there a length limit?
Yes, it's 9,223,372,036,854,775,807 bytes (8,388,608 terrabytes)
There is no (sane) limit on stream length.
You're looking for the HTTP response's ContentLength
property.
Stream.Length
is a long
, so its (positive) limit is 2^63
. It should be OK for you.
I have to read into memory a 2.9 Gbytes encrypted file and decrypt it. During the read into memory ( Using Bouncy Castle ), I get a Stream Length Limit Exception running in 64 bit mode. If I decrypt the file from the encrypted data file to another file, then read it into memory using a FileReader, I do not get the error and end up with the entire file in memory. I really need to decrypt directly into memory as the customer doesn't want PII data to reside on disk at any time, unencrypted. What would cause this Stream Length Exception, then?