c# Base64转图片并保存
直接保存图片失败
var bytes = Convert.FromBase64String(filecontent); var filecontent = Encoding.Default.GetString(bytes); File.WriteAllText(file, filecontent);
需使用以下代码
var bytes = Convert.FromBase64String(filecontent); using (var imageStream = new MemoryStream(bytes, false)) { Image image = Image.FromStream(imageStream); //ArgumentException: Parameter is not valid. image.Save(file); }