Free Support Forum - aspose.com

Is it possible to set aspose document equal to a byte array?

using licensed v2.1.5.0

we are exploring the possibility of storing doc templates in the database, these are then retrieved in the form of a byte array and then to be used to create aspose documents

but at the minute we are having problems setting the aspose document to the byte array.

we do not want to create a word doc on disk and then set the aspose document = to the created document.

Can this be done?

just found what i needed

Dim dr As OracleDataReader = command.ExecuteReader()

dr.Read()

Dim b(dr.GetBytes(PictureCol, 0, Nothing, 0, Integer.MaxValue) - 1) As Byte

dr.GetBytes(PictureCol, 0, b, 0, b.Length)

dr.Close()

connection.Close()

Dim streamIn As New System.IO.MemoryStream(b)

Dim doc As New Aspose.Word.Document(streamIn)

Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for asking this.

Your approach is right. To store documents as binary objects streams should be used. But note that it is not good to store many large files in a database. We had examples from customer practice which you can find in the forum: performance degradation, problems with replication etc. If you need thousands of such objects then some architectural optimization should be considered. Just be aware of this potential problem.

Regards,