mirzapirza
Technical User
It's not documented in the MSDN. The Read method is supposed to return the number of bytes read from the stream, or 0 if there's no more data.
Here's what I'm currently doing..
Any ideas on how this -1 should be handled? I can't seem to find it documented anywhere.
Here's what I'm currently doing..
Code:
// reader is a Stream
using(reader = new WebClient().OpenRead(url))
{
int read = 1;
byte[] buff = new byte[4096];
while(read != 0)
{
read = reader.Read(buff, 0, buff.Length);
if(read > 0)
writer.Write(buff, 0, read);
}
}
Any ideas on how this -1 should be handled? I can't seem to find it documented anywhere.