The InMemoryFileInfo.Length property returns Stream.Length of the underlying stream, regardless of the stream supporting seeking or not, which may lead to an NotSupportedException.
Solution:
Stream.Length should only be evaluated if the Stream.CanSeek is true.