41
You don't need to preallocate memory.
You can get the size afterwards with memoryStream.Length.
After you've done what you need to with your memoryStream, be sure to dispose it (or wrap it all in a using statement).