C# 常用方法——base64字符串转内存流
其他常用方法详见: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); return new MenoryStream(arr); } catch (Exception ex) { throw ex; } }