I need to decode a base64 image and display it in a PictureBox control.
Currently I get an "Invaild character in a Base-64 string." error, so not
sure if a bad file or bad code, I have:
byte[] arrBytes = new Byte[5419];
// read the file from disk
System.IO.FileStream fs = System.IO.File.OpenRead("../../Photo.jpg");
arrBytes = new byte[fs.Length];
fs.Read(arrBytes, 0, (int)fs.Length - 1);
fs.Close();
// convert to string, decode and place in control
string s = System.Text.Encoding.ASCII.GetString (arrBytes);
byte[] b = Convert.FromBase64String(s);
// at this a point an exception is throw
System.IO.MemoryStream m = new System.IO.MemoryStream(b);
PhotoPictureBox.Image = System.Drawing.Image.FromStream(m);
__________________________________________________ ____
Question: Should this work and is this the best way?
Thanks for the help! Steve