I have a form with multiple FileUpload (around 8) and then i want to attach these uplaoded files to a message. The uplaoded files would be only images and i need to do some resizing of the image and for which i amusing a control aspJPEG. I am using below code and it works fine with IE but as soon as i try this code on another browser on MAC ,it gives me an error and some times on IE too
The process cannot access the file (path) because it is being used by another process.
how can i get away from this error. I am disposing object as well ,but please can some one check and see whats the matter ,or i have disposed objects at wrong place or i am missing some thing
any help would be appriciated. I am using Visual web developer 2010 with .net 4.0
if some body want to try it LIVE its here: http://www.taylorus.com/buyusedequip/
thanks
Code:HttpFileCollection UploadFileCol = Request.Files; for (int i = 0; i < UploadFileCol.Count; i++) { HttpPostedFile file = UploadFileCol[i]; if (file.ContentLength > 0) { strFileName = Path.GetFileName(file.FileName); fullyqualifidespath = Server.MapPath("~/uploads/" + strFileName); file.SaveAs(fullyqualifidespath); file.InputStream.Dispose(); ASPJPEGLib.IASPJpeg objJpeg; objJpeg = new ASPJPEGLib.ASPJpeg(); // Open source image objJpeg.Open(fullyqualifidespath); if (objJpeg.OriginalWidth > objJpeg.OriginalHeight) { objJpeg.Width = 400; objJpeg.Height = objJpeg.OriginalHeight * objJpeg.Width / objJpeg.OriginalWidth; } if (objJpeg.OriginalWidth < objJpeg.OriginalHeight) { objJpeg.Width = 300; objJpeg.Height = objJpeg.OriginalHeight * objJpeg.Width / objJpeg.OriginalWidth; } objJpeg.Save(fullyqualifidespath); objJpeg.Close(); msg.Attachments.Add(new Attachment(fullyqualifidespath)); } } SmtpClient client = new SmtpClient("someserver.net", 25); client.Credentials = CredentialCache.DefaultNetworkCredentials; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Send(msg); msg.Attachments.Dispose(); msg.Dispose(); Response.Redirect("thankyou.aspx");




Reply With Quote