Hi,
I think your base 64 string is incorrect. How did you convert it to base 64 ?
You can validate your Base 64 string like this:
public bool IsBase64String(string s)
{
s = s.Trim();
return (s.Length % 4 == 0) && Regex.IsMatch(s, @"^[a-zA-Z0-9\+/]*={0,3}$", RegexOptions.None);
}
Then you can call it like this:
public void LoadImage()
{
string string64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==";
bool isStringValid = this.IsBase64String(string64);
if (isStringValid)
{
byte[] bytes = Convert.FromBase64String(string64);
System.Drawing.Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = System.Drawing.Image.FromStream(ms);
}
}
}