In my application, I save an Excel object to a stream using the following code:
Stream stream = new MemoryStream();
At first, I was doing this in two different places in my code - firstly to attach the file to an email, secondly to display the size of the file on a web page. However, the second time that I saved the Excel object, the stream's lenth was 4096 bytes instead of 6411 bytes (or something similar). I didn't test opening the file this second time, so I don't know if any corruption also occurred.
I got around this issue by only saving to a stream once. However, is there an issue with the way I was trying to save or is there a possible bug with this?