.net core A generic error occurred in GD 已解决
方法一。比较坑
using MemoryStream ms = new MemoryStream(arr);
Bitmap bitmap = new Bitmap(Image.FromStream(ms));
bitmap.Save(webRootPath,ImageFormat.Png);
bitmap.Dispose();
ms.Close();
ms.Dispose();
在Save方法是老是 报错 A generic error occurred in GDI+.
方法二。比较推荐
byte[] arr = Convert.FromBase64String(strbase);
string filepath = Path.GetDirectoryName(path);
// 如果不存在就创建file文件夹
if (!Directory.Exists(filepath))
{
if (filepath != null) Directory.CreateDirectory(filepath);
}
System.IO.File.WriteAllBytes(path, arr);