How to convert varBinary into image or video when retrieved from database in C#

前端 未结 4 1843
孤街浪徒
孤街浪徒 2021-01-16 06:31

I am using visual studio 2010, (desktop application) and using LINQ to SQL to save image/video or audio files to database in dataType VarBinary (MAX). This I ca

4条回答
  •  孤街浪徒
    2021-01-16 07:31

    It's very easy, if you have a binary data and want to create an Image object, use this code:

    public Image BinaryToImage(byte[] binaryData)
    {
         MemoryStream ms = new MemoryStream(binaryData);
         Image img = Image.FromStream(ms);
         return img;
    }
    

提交回复
热议问题