Renaming or deleting a displayed imgae
-
Christian Graus wrote:
I am certain that there have been times that I've disposed of the image and it's still held onto the file
Yup - I've seen this. It seems to depend (to a certain extent) on how the image was opened in the first place.
Deja View - the feeling that you've seen this post before.
Pete O'Hanlon wrote:
It seems to depend (to a certain extent) on how the image was opened in the first place.
That makes sense. Disposing the Bitmap to make it release the file only works if it's actually the Bitmap that is holding on to the file. The Bitmap should always be disposed, of course, even if it's not to release the file.
Despite everything, the person most likely to be fooling you next is yourself.
-
Christian Graus wrote:
I am certain that there have been times that I've disposed of the image and it's still held onto the file
Yup - I've seen this. It seems to depend (to a certain extent) on how the image was opened in the first place.
Deja View - the feeling that you've seen this post before.
Yeah "Deja View" I know I have seen this issue before but after spending many hours with Google etc. to no avail I resorted to asking for help. Many thanks Code Project. I try not to ask questions unless I have exhausted all alternatives. Thanks for your help I now have greater insight into the issue than my simple problem required.
-
electriac wrote:
How do I release the resources for an image so I can rename or delete it.
Dispose it!
pic.Dispose();
pic=null;GDI+ keeps the image stream open until you dispose the image. It's buried way deep in the documentation - like a one sentence blurb in an overview somewhere. :) You can work with a clone as well, like Christian mentioned. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Yeah be very careful with anything that wraps GDI functionality. Even innocent looking things like Matrix implement IDisposable. :( Check, double-check, etc.
Mark Churchill Director, Dunn & Churchill Pty Ltd Free Download: Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.
Alpha release: Entanglar: Transparant multiplayer framework for .Net games. -
Hey there, it was my post about a month ago you're talking about:) Glad you found the solution:), One more problem is in the pictureBox control "when loading it with a bitmap", more details are on msdn website..
All generalizations are wrong, including this one! (\ /) (O.o) (><)
-
Yeah "Deja View" I know I have seen this issue before but after spending many hours with Google etc. to no avail I resorted to asking for help. Many thanks Code Project. I try not to ask questions unless I have exhausted all alternatives. Thanks for your help I now have greater insight into the issue than my simple problem required.
electriac wrote:
I know I have seen this issue before but after spending many hours with Google etc
That's the spirit. BTW - don't think that Deja View referred to your problem. It's part of my sig.
Deja View - the feeling that you've seen this post before.
-
Hey there, it was my post about a month ago you're talking about:) Glad you found the solution:), One more problem is in the pictureBox control "when loading it with a bitmap", more details are on msdn website..
All generalizations are wrong, including this one! (\ /) (O.o) (><)
-
electriac wrote:
I know I have seen this issue before but after spending many hours with Google etc
That's the spirit. BTW - don't think that Deja View referred to your problem. It's part of my sig.
Deja View - the feeling that you've seen this post before.
-
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/91bffae9-c78e-458b-b23c-42cee71f7669/[^]
All generalizations are wrong, including this one! (\ /) (O.o) (><)
Muammar Thanks for the link. I am doing a rewrite of my media player which displays images associated with the MP3 files. Since the program also deletes, renames, and exports groups of files I have had some difficulty do to the problem of unreleased resources. I believe that with the help of all you "Code Project" people I have everything working now. Thanks to all Electriac
-
I did think it was a cute reference to my inability to find the previous post about picture boxes.
No - if you look at my profile history, you'll see this in all my posts. I've been using it for 3 years now.
Deja View - the feeling that you've seen this post before.