Image File Not getting Deleted (IO Exception)

A

Aryan

Hi All,
I am creating an image(.gif) file on server Using ASP and ShotGraph
Third Party Tool, now with the help of this .gif image I am creating
another Thumbnail image in ASP.NET.
Now this newly created Thumbnail is been shown in ASP.NET page in
IFrame, I have delete Button in my ASP.NET page, Now on Click of this
Delete Button i want to delete both the images.
But I am not able to delete that .gif file which is been created by
ASP page using ShotGraph, it gives me IO Exception, it says that "files
is been used by another process".

So how can i delete this file from my ASP.NET code(i am using VB.NET as
code base).

Please help me out.

Thanks in Advance

Manoj Singh.
 
M

Markus

But I am not able to delete that .gif file which is been created by
ASP page using ShotGraph, it gives me IO Exception, it says that
"files is been used by another process".

Make sure, no other process has this picture opened. I can just guess,
as I don't have any insight in your code, but maybe you are opening the
image with
Image img = Image.FromFile(...);
and then you never dispose the image with
img.Dispose();
So a reference to the image is kept and so it is still marked as "in use".

Two solutions:
1) Call dispose whenever you open an image.
2) Use Image.FromStream() instead of Image.FromFile()

hope I am good in guessing... try to give more information on your
questions for not letting us guess!

hope to help anyways
Markus
 
P

Patrice

Plus if all else fails, it could be caused by IIS (AFAIK files are locked
for short period of time when displayed through IIS).
 
A

Aryan

Hello Friends,
I am not Using that .gif image any where other then creating
Thumbnail Image from it. So my ASP code creates that gif image and then
sends the path of that .gif image to ASP.NET page and then ASP.NET page
creates Thumbnail Image from that original gif image. And now this
newly created Thumbnail Image is been shown in IFrame.
So problem is, i am able to delete that newly created Thumbnail
Image, but that old gif image is not getting deleted. So at this point
i am getting error. And i am closing and disposing all the objects
which creates that Thumbnail Images


Thanks All of You,
Manoj Singh.
 
A

Aryan

Hello Friends,
Thanks for all your help and support. With your help i could solve my
problem.

Thanks Again
Manoj Singh.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top