Free Support Forum - aspose.com

How to create a word document directly into MemoryStream?

Hello,I have a new question in coding:

I create a word report in server,I want to let users download the it to his local machine,now I use "doc.Save(....)" to save the file first,and then generate a memory to download to users' local,I know this way is so slowly,can I directly create a word document into MemoryStream without saving to the server ?

Hi

Thanks for your request. You can save your document directly into MemoryStream. See the following link for additional information.

http://www.aspose.com/Products/Aspose.Words/Api/SavingtoaStream.html

Or if you use .NET version of Aspose.Words, you can save document to client browser. See the following link.

http://www.aspose.com/Products/Aspose.Words/Api/SendingtoaClientBrowser.html

I hope that it will help you.

The links seems to have broken. Need help in saving the doc to a MemoryStream.

thanks

Hi

Thanks for your inquiry. You can use the following code.

MemoryStream stream = new MemoryStream();

doc.Save(stream, SaveFormat.Doc);

Please let me know if you would like to know something else.

Best regards.