Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, July 15, 2010 6:18 AM
How can I convert byte to byte[]?
public byte[] EmpPic;
empObj.EmpPic = dataRow["empPic"]; [NB: empPic is image type in database]
error is:
Cannot implicitly convert type 'byte' to 'byte[]'
All replies (2)
Thursday, July 15, 2010 6:47 AM ✅Answered
byte[] img = (byte[])(Convert.FromBase64String(dr["value"].ToString()));
Thursday, July 15, 2010 6:55 AM ✅Answered
byte[] img =Convert.FromBase64String(dataRow["empPic"].ToString());
subject to the condition that your image is image's base64 representation (pure text), and not its pure binary representation.
otherwise,
see this post for more information