I have a problem with my program. I read byte[]
from a SQL Server database and save this as a JPEG image.
while (reader1.Read())
{
picBytes = null;
picBytes = (byte[])reader1.GetValue(0);
if (picBytes != null)
{
try
{
ms = new MemoryStream(picBytes, 0, picBytes.Length);
returnImage = Image.FromStream(ms, true);
returnImage.Save(@"path" + array[2] + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
returnImage.Dispose();
ms.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e + array[2] + ".jpg");
}
}
}
I have read that in 99% there are permissions errors but 500 images are created correctly and 50 are not.
And this error is only thrown under Windows 7 64Bit... with XP there are no problems:
Error in System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
There are still a few who have the same problem, so here how i solve the problem:
use