public bool CheckImageSize(HttpPostedFileBase aFile) { bool isValid = false; if (aFile.ContentLength > 0) { try { System.Drawing.Image imageObj = System.Drawing.Image.FromStream(aFile.InputStream); //error generated here if ((imageObj.Width == 640 && imageObj.Height == 960) || (imageObj.Width == 640 && imageObj.Height == 1136) || (imageObj.Width == 768 && imageObj.Height == 1024) || (imageObj.Width == 1536 && imageObj.Height == 2048)) { isValid = true; } } catch (Exception ex) { return false; } } return true; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)