hi , i open an image whit the below code :
protected void Page_Load(object sender, EventArgs e)
{
string imagePath = Server.MapPath(PublicClass.ImgPath()) + "3_nissan-cars-logo-emblem.jpg";
Image originalImage = Image.FromFile(imagePath);
System.Drawing.Image image;
image = ResizeImage(originalImage, 100, 100);
Response.ContentType = "image/Jpeg";
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
public static System.Drawing.Image ResizeImage(System.Drawing.Image image, int maxWidth, int maxHeight)
{
int newWidth = 0, newHeight = 0;
if ((image.Width > maxWidth || image.Height > maxHeight) && maxWidth > 0 && maxHeight > 0)
{
newWidth = maxWidth;
newHeight = image.Height * newWidth / image.Width;
var newImage = new Bitmap(maxWidth, newHeight);
using (var graphic = Graphics.FromImage(newImage))
{
graphic.DrawImage(image, 0, 0, newWidth, newHeight);
}
return newImage;
}
else
if (maxWidth > 0 && maxHeight > 0)
{
var newImage = new Bitmap(image.Width, image.Height);
using (var graphic = Graphics.FromImage(newImage))
{
graphic.DrawImage(image, 0, 0, image.Width, image.Height);
}
return newImage;
}
else
return image;
}
and i would like to delete image from my directory while its open and i get error regarding "image is running in another proccessor"
please help me that how to show image whit my above code and discard its stream to can delete it . thank you .