其他常用方法详见:https://www.cnblogs.com/zhuanjiao/p/12060937.html
/// <summary> /// base64编码的文本转为图片 /// </summary> /// <param name="base64Str"></param> /// <param name="savePath"></param> public MemoryStream Base64StringToImage(string base64Str) { try { //将base64头部信息替换 base64Str = base64Str.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "") .Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", ""); byte[] arr = Convert.FromBase64String(base64Str); using (MemoryStream ms = new MemoryStream(arr)) { return ms; } } catch (Exception ex) { throw ex; } }