protected void rauIMAGE_ValidatingFile(object sender, Telerik.Web.UI.Upload.ValidateFileEventArgs e) { //we will check image height and width if (rauIMAGE.UploadedFiles.Count > 0) { foreach (UploadedFile theFile in rauIMAGE.UploadedFiles) { //Stream stream = theFile.InputStream; (when uncomment problem occurs) //using (System.Drawing.Bitmap myImage = new System.Drawing.Bitmap(stream,false)) //{ // if (myImage.Width > 128 || myImage.Height > 128) // { // master.ShowMessage("Image bigger than width :300px by height: 100px not allowed", null, ""); // e.IsValid = false; // } //} //e.SkipInternalValidation = true; } } }In the above code block I try to determine uploaded image width and height to be able to prevent from uploading image size larger than (128x128)
but when use inputstream to create new image object I come across with strange error. Also
System.Drawing.Bitmap myImage = new System.Drawing.Bitmap(stream,false) error
System.Drawing.Bitmap myImage = new System.Drawing.Bitmap(theFile.InputStream,false) error
System.Drawing.Bitmap myImage = new System.Drawing.Bitmap(128,128) no error when also comment this line--> (Stream stream = theFile.InputStream)
Do you have any idea about that strange error ??