When you have a file part with the correct length, placing the endboundary just at the end of a buffer leaving out the "--" it will be seen as a simple boundary giving exceptions in the next section.
I changed the code to:
else if (boundaryPos >= 0 && endBoundaryPos < 0)
{
// if the boundary is at the and of the buffer, it can be a potential endboundry where the "--" was just missed
// if so, don't mark it as an end, so another buffer will be read
if (boundaryPos + boundaryLength < (this.BinaryBufferSize * 2) - 2)
{
// Select boundary
endPos = boundaryPos;
endPosLength = boundaryLength;
}
}
When you have a file part with the correct length, placing the endboundary just at the end of a buffer leaving out the "--" it will be seen as a simple boundary giving exceptions in the next section. I changed the code to: