How can get the stream bytes back from the updated aspose document

Hi All
We are using Aspose word to generate word document based on word document template…
Form the server I get the bytes info of the file, and created the memory stream… )not suppose to store on the disk at any point of time)

memoryStream = new MemoryStream(fileBytesFromtheServer,true);
_asposeDocument = new Document(memoryStream);

Then loops through the each of the book marks and replaced the text with specific text.
Then saved the updated document to a new memory stream in the SaveFormart.Doc
Then I read the newly created memory stream to get the bytes info…

byte [] bytes = new bute(newly created memory stream length)
newlycreatedMemoryStream.Read(bytes,0, newly created stream lenghth)...

But using the read byte If I create the attachment document its content zero… nothing is displayed when I open the attachement…
Attachement logic is fine, becasuse its works in all other places…
I am missing any thing here…
Thanks in advance
Ranganatha

Hi
Thanks for your inquiry. Please try using the following code:

MemoryStream outputStream = new MemoryStream();
doc.Save(outputStream, SaveFormat.Doc);
byte[] outputBytes = outputStream.GetBuffer();

Hope this helps.
Best regards.

Hi Alexey Noskov,
Thanks a lot… Its solved the issue…Now I can open the attachment…
Ranganatha