public virtual int length() { int len; len = (int) theFile.Length; // If the position in the buffer is not past the end of the file, // the length of theFile is the length of the stream if ((offset + maxByte) <= len) { return (len); } else { // If not, the file is extended due to the buffering return (offset + maxByte); } }