Bitmap Dispose() Problem

  • Thread starter Thread starter Manuel Adam
  • Start date Start date
M

Manuel Adam

Hello!

I am using an web application to resize some JPG files.
First I use WebClient to download the Image from the Web.
Then I use the Bitmap Class to Save it as a different file.
Later I delete the bigger picture.

I had some trouble to resize Gif files with my function. So I used to
convert Gif to Jpg first.
Then I used the same as rescribed before.

The problem is that when I try to delete the converted Gif->JPG file,
I always get the error: File In use.

I used:
Bitmap myBitmap = Bitmap(gif_file);
myBitmap.Save("new.jpg",ImageFormat.Jpeg);
myBitmap.Dispose();
// myBitmap != null

Dispose() works so far,
I can delete gif_file using File.Delete(gif_file);

BUT I cannot delete new.jpg ?
Only later in Explorer.

What could be wrong?

Manuel
 
Back
Top