我該如何解決這個GDI泛型異常?如何在保存圖像時修復此GDI +泛型異常?
這裏是例外:
System.Runtime.InteropServices.ExternalException was unhandled
HResult=-2147467259
Message=A generic error occurred in GDI+.
Source=System.Drawing
ErrorCode=-2147467259
代碼:
public Bitmap resize(string FileName)
{
string[] settings;
string inputFolder = "";
string qrFolder = "";
string generalFolder = "";
string archiveFolder = "";
string resizedArchiveFolder ="";
string line;
int index = 0;
settings = System.IO.File.ReadAllLines("config.txt");
foreach (string setting in settings)
{//access to config file info
var arr = setting.Split('=');
if (index == 0)
inputFolder = arr[1];
else if (index == 1)
qrFolder = arr[1];
else if (index == 2)
generalFolder = arr[1];
else if (index == 3)
resizedArchiveFolder = arr[1];
else
archiveFolder = arr[1];
index++;
}
string targetPath = resizedArchiveFolder;
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
}
Bitmap a2 = (Bitmap)Image.FromFile(FileName);
//load file
a2 = new Bitmap(a2, new Size(a2.Width * 3/2, a2.Height * 3/2));
a2.SetResolution(1920, 1080);
a2.Save(resizedArchiveFolder + System.IO.Path.GetFileName(FileName));
// it throws here when I save
return a2;
}
什麼是例外? –