Karthi Keyan

Karthi Keyan

  • 1k
  • 755
  • 237k

Exception : Out of Memory.

Jun 27 2018 5:45 AM
Hi guys,
 
I got Out of Memory Exception while run the below code. I dont know how to resolve this. Will appreciate if somebody help me.
 
foreach (var file in Directory.GetFiles(Path.GetDirectoryName(txtinputimage.Text) + "\\Thumbnail").ToList().Where(k => !k.EndsWith(".thumb")))
{
   Image image = Image.FromFile(file);    // Got the Exception in this line.
   Image thumb = image.GetThumbnailImage(180, 120, () => false, IntPtr.Zero);
   thumb.Save(Path.ChangeExtension(file, "thumb"));   
   image.Dispose();
   thumb.Dispose();
   File.Delete(file);
}
 
 

Answers (2)