Pergunta

I'm using MS SQL 2008 i have a table with varbinary(max) type column
This table has many uploaded pdf files (byte arrays)
I'm converting this bytes to pdf files
by this code:

using (FileStream fs = new FileStream
                (@"D:\EIFiles\test.pdf", FileMode.Create))
        {
            fs.Write(byte, 0, byte.Length);
        } 

Many of the pdf files can be opened, but some of them can not be open because adobe reader alerts "damaged file" message. Note: All of them can be open via program (written in Devexpress XAF) which uses this DB

Foi útil?

Solução

The DevExpress XAF implementation of the default FileData type compresses the stream (Gzip) before saving it. You will not be able to read the contents without decompressing the stream first. You can use CompressionUtils.Decompress() which is in the DevExpress.Persistent.Base assembly.

Alternatively you could implement your own version of FileData and change this behaviour. Look at the source (or use a decompiler) and remove the [ValueConverter(typeof(CompressionConverter))] attribute from the Content property.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top