If the given value is less than the current length of the stream, the stream is truncated. If the given value is larger than the current length of the stream, the stream is expanded. If the stream is expanded, the contents of the stream between the old and the new lengths are undefined.
A stream must support both writing and seeking for UnmanagedMemoryStream.SetLength(long) to work.