would have only saved the resized images

Posted by saadan on Stack Overflow See other posts from Stack Overflow or by saadan
Published on 2010-05-26T06:36:11Z Indexed on 2010/05/26 6:41 UTC
Read the original article Hit count: 304

Filed under:
|
|
|

I want it to only saves the resized images so have tried to do so it deletes the original image again after it has been uploaded but can not because it says the image is being used by another process please help.
and can not simply remove where it stores the original because it uses it to resize

i Use this code to save the fils

                        string tempPath = "Galleryt";
                        string imgPath = "Gallery";
                        string savePath =  Path.Combine(Request.PhysicalApplicationPath, tempPath);
                        string imgSavePath = Path.Combine(Request.PhysicalApplicationPath, imgPath);
                        string imgSavePath2 = Path.Combine(Request.PhysicalApplicationPath, imgPath);
                        string ProductImageNormal = Path.Combine(imgSavePath, imageName + Fileupload1.PostedFile.FileName);
                        string ProductImagetemp = Path.Combine(savePath, "t__" + imageName + Fileupload1.PostedFile.FileName);
                        string ProductImagetemp2 = Path.Combine(imgSavePath2, "b__" + imageName + Fileupload1.PostedFile.FileName);
                        string extension = Path.GetExtension(Fileupload1.PostedFile.FileName);

                        switch (extension.ToLower())
                        {
                            case ".png": goto case "Upload";
                            case ".gif": goto case "Upload";
                            case ".jpg": goto case "Upload";
                            case "Upload": Fileupload1.PostedFile.SaveAs(ProductImageNormal);
                                ImageTools.GenerateThumbnail(ProductImageNormal, ProductImagetemp, 250, 350, true, "heigh");
                                ImageTools.GenerateThumbnail(ProductImageNormal, ProductImagetemp2, 600, 600, true, "heigh");

                                Label1.Text = "";
                                break;
                            default:
                                Label1.Text = "Status: Denne filtype er ikke tilladt";
                                return;

                        }
                    }

if i try to delete the original file just after with code

 File.Delete(Server.MapPath("~/Gallery/" + imageName + Fileupload1.PostedFile.FileName));

© Stack Overflow or respective owner

Related posts about c#

Related posts about image