byte array to pdf

前端 未结 2 477
北恋
北恋 2020-12-29 02:25

I am trying to convert content of a file stored in a sql column to a pdf.

I use the following piece of code:

byte[] bytes;
BinaryFormatter bf = new B         


        
2条回答
  •  情深已故
    2020-12-29 02:46

    Usually this happens if something is wrong with the byte array.

    File.WriteAllBytes("filename.PDF", Byte[]);
    

    This creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.

    Asynchronous implementation of this is also available.

    public static System.Threading.Tasks.Task WriteAllBytesAsync 
    (string path, byte[] bytes, System.Threading.CancellationToken cancellationToken = null);
    

提交回复
热议问题