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);
}