I have an ASP.NET C# page where i am resizing the images in a folder .I am using GDI+ to do this.I want to resize the images and replace with the old images.So when i am trying to save with the existing name ,Save method is throwing an error .But if i give a different name it is getting saved.But i want to have the same file name for the newly created resized image as i need to overwrite the existing file with the new file which is resized. Any idea how to go ahead. My code is
oldImagePath= oldImagePath.Replace(".jpg", "NEW.jpg");
try
{
ImageCodecInfo[] Info = ImageCodecInfo.GetImageEncoders();
EncoderParameters Params = new EncoderParameters(1);
Params.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
target.Save(oldImagePath, Info[1], Params);
}
if i comment the first line which creates a new name for the destination file, IT will not work.,other wose it will.But i want to have the same name .Any thought ?? ? Thanks in advance