c# - Why does FileStream feed FtpWebRequest but not MemoryStream? -
i'm using msdn example here: http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
i changed filestream memorystream , doesn't read bytes
when change filestream works fine.
any clue?
thanks
compressmemorystream(); stream requeststream = _request.endgetrequeststream(ar); const int bufferlength = 2048; byte[] buffer = new byte[bufferlength]; int count = 0; int readbytes = 0; { //memorystream _compressedoutstream //is created/filled 'compressmemorystream()' readbytes = _compressedoutstream.read(buffer, 0, bufferlength); requeststream.write(buffer, 0, readbytes); count += readbytes; } while (readbytes != 0); requeststream.close(); state.request.begingetresponse( new asynccallback(endgetresponsecallback), state );
what's value of readbytes
on first iteration through loop?
my first guess made same mistake make: writing stream, forgetting rewind beginning before starting read it. if that's case, readbytes
0 on first (and only) loop iteration, because you're @ end of stream -- there's nothing read.
try setting stream.position = 0
before start reading.
Comments
Post a Comment