Last post Jul 13, 2018 03:12 AM by Yuki Tao
Jul 12, 2018 05:56 AM|lolo123|LINK
I'm trying to resize an image proportionally using the below code
Image sourceimage = Image.FromStream(mainImg.InputStream); //mainImg is of type HttpPostedFileBase
Guid g = Guid.NewGuid();
string fileName = g + "_" + System.IO.Path.GetFileName(mainImg.FileName);
Image thumbnail = TheGateMain.Helpers.ImageResize.resizeMyImage(sourceimage, new Size(525,328));
string thumbnailsPath = System.IO.Path.Combine(
//error is thrown here when saving the thumbnail
This is function of resizing the image
public static Image resizeMyImage(Image imgToResize, Size size)
return (Image)(new Bitmap(imgToResize, size));
please advice urgent
Thanks in advance
Jul 12, 2018 07:54 AM|vahid bakkhi|LINK
Most often, this error occurs because the user account (NETWORK SERVICE) doesn't have permission to write to the location you are trying to save the file at. You need to apply WRITE permissions to the UserImages folder.
please try below code :
Jul 13, 2018 03:12 AM|Yuki Tao|LINK
According to your code, I make a demo.
Like the picture:
I can't reproduce your issue,because it did not throw any error here.
I can save and resize an image successfully.
As far as I know,this error message is also displayed if the path you pass to .Save() is invalid (folder doesn't exist etc).
So,you could check if the path is valid.