We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Saving document to a MemoryStream

Hello, I have a problem saving a document to a MemoryStream: when I try to access the stream after the Save method it is closed and thus inaccessible. I think this is a convenient way for a FileStream (the bytes are written and the stream is closed) but what can I do to obtain the contained document as a byte array (to save for example in a database field) ? === IWordDocument doc = new WordDocument(); Stream _str = new MemoryStream(_dataRow.Document); doc.Open(_str, Syncfusion.DocIO.FormatType.Doc); doc.MailMerge.Execute(_dsDom.Domanda); Stream _targetStream = new MemoryStream(); doc.Save(_targetStream, Syncfusion.DocIO.FormatType.Doc); _targetStream.Read(anotherDataRow.Document, ... *Exception*

2 Replies

AD Administrator Syncfusion Team March 24, 2006 01:36 PM UTC

Hi Giorgio, This is a known bug that has already been addressed. I will post the updated assemblies in a couple of hours. Thank you for your patience. Best regards, Stephen. >Hello, >I have a problem saving a document to a MemoryStream: when I try to access the stream after the Save method it is closed and thus inaccessible. I think this is a convenient way for a FileStream (the bytes are written and the stream is closed) but what can I do to obtain the contained document as a byte array (to save for example in a database field) ? > >=== >IWordDocument doc = new WordDocument(); >Stream _str = new MemoryStream(_dataRow.Document); >doc.Open(_str, Syncfusion.DocIO.FormatType.Doc); >doc.MailMerge.Execute(_dsDom.Domanda); >Stream _targetStream = new MemoryStream(); >doc.Save(_targetStream, Syncfusion.DocIO.FormatType.Doc); >_targetStream.Read(anotherDataRow.Document, ... *Exception* > >


AD Administrator Syncfusion Team March 27, 2006 09:16 AM UTC

Hi Giorgio, This defect has been fixed, here are the updated assemblies Syncfusion.DocIO.Base.zip Best regards, Stephen. >Hi Giorgio, > >This is a known bug that has already been addressed. I will post the updated assemblies in a couple of hours. Thank you for your patience. > >Best regards, > >Stephen. > >>Hello, >>I have a problem saving a document to a MemoryStream: when I try to access the stream after the Save method it is closed and thus inaccessible. I think this is a convenient way for a FileStream (the bytes are written and the stream is closed) but what can I do to obtain the contained document as a byte array (to save for example in a database field) ? >> >>=== >>IWordDocument doc = new WordDocument(); >>Stream _str = new MemoryStream(_dataRow.Document); >>doc.Open(_str, Syncfusion.DocIO.FormatType.Doc); >>doc.MailMerge.Execute(_dsDom.Domanda); >>Stream _targetStream = new MemoryStream(); >>doc.Save(_targetStream, Syncfusion.DocIO.FormatType.Doc); >>_targetStream.Read(anotherDataRow.Document, ... *Exception* >> >>

Loader.
Live Chat Icon For mobile
Up arrow icon