Question: Why is MemoryStream having a Null buffer even after checking if the Stream contains any bytes?
The error says "An unhandled exception has occurred while executing the request.
System.ArgumentNullException: Value cannot be null. (Parameter 'buffer')"
if(memeryStream is not null && memoryStream.Lenght > 0)
//Execute
The null checking will execute first before checking the length, if you check the length first the Exception will throw.