EldoS | Feel safer!

Software components for data protection, secure storage and transfer

CbFsReadFileEvent buffer size

Posted: 04/15/2011 16:24:57
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 70


I'm trying to implement file reading form a remote storage (web) reading from HttpWebResponse stream.

When some application (Windows Explorer or FAR) reads 100 Kbytes file from a mounted disk, I receive CbFsReadFileEvent with 64K buffer size.

When I read from my WebStream, it returns only 3764 bytes on first read.

If I pass it back as return values (BytesRead = 3764, while BytesToRead is 65536), the application (FAR) says "device general failure" and I do not receive any CbFsReadFileEvent anymore.

Then I implemented reading in cycle until all requested data are read, or until end-of-webstream. And it helped.

.Net's int Stream.Read() method can return less bytes than requested if data not yet available, so subsequent calls are needed to read whole data.
And only value 0 indicates that the stream has ended and there's no more data will be returned by subsequent calls.

The documentation on CbFsReadFileEvent doesn't say that I cannot return less data than requested.

So the question: is it expected behavior that I need to read all data requested by CbFsReadFileEvent and cannot return less bytes? If so, could you reflect it in the documentation?

Posted: 04/15/2011 23:15:21
by Eugene Mayevski (Team)

Yes, you must return exactly the same number of bytes that have been requested. We will update documentation.

.NET's Stream class is generic, so it was designed to allow reading or writing less than requested. But this doesn't mean that this is expected behavior.

Sincerely yours
Eugene Mayevski



Topic viewed 993 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!