Convert image to binary?

前端 未结 8 2204
南旧
南旧 2021-02-08 04:07

I have an image (in .png format), and I want this picture to convert to binary.

How can this be done using C#?

8条回答
  •  既然无缘
    2021-02-08 04:35

    using System.IO;
    
    FileStream fs=new FileStream(Path, FileMode.Open, FileAccess.Read); //Path is image location 
    Byte[] bindata= new byte[Convert.ToInt32(fs.Length)];
    fs.Read(bindata, 0, Convert.ToInt32(fs.Length));
    

提交回复
热议问题