On 11/10/2005 15:43, Ice Shock wrote:
I know that Microsoft might be the dummest but this beats all. I got the do
while loop from microsoft itself and the readToEnd works while the loop does
not. Can u explain why reading on multiple phases in a loop would not work
while the readToEnd would? thank you...
Your loop code:
char [] data = new char[1048576];
int nBytes;
do
{
nBytes = sr.Read(data, 0, (int) 1048576);
sb.Append(data);
}
while(nBytes == 1048576);
From the docs for StreamReader.Read():
Return Value
The number of characters that have been read, or 0 if at the end of the
stream and no data was read. The number will be less than or equal to
count, depending on whether the data is available within the stream.
The while test should be while(nBytes > 0) to keep looping until you
reach the end of the stream. Otherwise your method will not receive all
the data if not all of it has arrived yet.
As to the question of it being "synch", I think that just refers to the
way you call the method that actually puts the data to your buffer, than
how it handles the data arriving.
Barnaby
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com