File.Delete problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I get 'file in use' exception when I call File.Delete("myFile.jpg").
But I can't see any reason for that. The file is open by any application.
I have loaded the file into an PictureBox.Image earlier, but after that I
have made
Image.Dispose() and Image = null and GC.Collect().
So the question is: Why is the .JPG file still 'in use' ???
 
Hi,

what is the fram work u are using..? I did it with framework 1.1 and worked
for me
Nirosh
 
Hi,

How r u reading the file in the first place?
You needs to create an Image instance first, how are you doing it?

tip:
you can use sysinternal.com tool to see what process has open the file. in
this way you can see who is using it.


cheers,
 
I think Bob Powell (MVP) has addressed the problem on his 'faq' site.
The trick seems to be to make a copy of the image immediately, and release
the original ImageFromFile object. (On the other hand I actually used the
method new Bitmap(filename).)

http://www.bobpowell.net/faqfeed.xml
 
Back
Top