Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Renaming or deleting a displayed imgae

Renaming or deleting a displayed imgae

Scheduled Pinned Locked Moved C#
graphicshelpquestionannouncement
17 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Pete OHanlon

    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.

    My blog | My articles | MoXAML PowerToys

    G Offline
    G Offline
    Guffa
    wrote on last edited by
    #8

    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.

    1 Reply Last reply
    0
    • P Pete OHanlon

      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.

      My blog | My articles | MoXAML PowerToys

      E Offline
      E Offline
      electriac
      wrote on last edited by
      #9

      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.

      P 1 Reply Last reply
      0
      • M Mark Salsbery

        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:

        M Offline
        M Offline
        Mark Churchill
        wrote on last edited by
        #10

        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.

        1 Reply Last reply
        0
        • E electriac

          Thanks Mark that did the trick!

          M Offline
          M Offline
          Muammar
          wrote on last edited by
          #11

          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) (><)

          E 1 Reply Last reply
          0
          • E electriac

            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.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #12

            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.

            My blog | My articles | MoXAML PowerToys

            E 1 Reply Last reply
            0
            • M Muammar

              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) (><)

              E Offline
              E Offline
              electriac
              wrote on last edited by
              #13

              Do you have a URL for that I was not able to find it with a search.

              M 1 Reply Last reply
              0
              • P Pete OHanlon

                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.

                My blog | My articles | MoXAML PowerToys

                E Offline
                E Offline
                electriac
                wrote on last edited by
                #14

                I did think it was a cute reference to my inability to find the previous post about picture boxes.

                P 1 Reply Last reply
                0
                • E electriac

                  Do you have a URL for that I was not able to find it with a search.

                  M Offline
                  M Offline
                  Muammar
                  wrote on last edited by
                  #15

                  http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/91bffae9-c78e-458b-b23c-42cee71f7669/[^]


                  All generalizations are wrong, including this one! (\ /) (O.o) (><)

                  E 1 Reply Last reply
                  0
                  • M Muammar

                    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/91bffae9-c78e-458b-b23c-42cee71f7669/[^]


                    All generalizations are wrong, including this one! (\ /) (O.o) (><)

                    E Offline
                    E Offline
                    electriac
                    wrote on last edited by
                    #16

                    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

                    1 Reply Last reply
                    0
                    • E electriac

                      I did think it was a cute reference to my inability to find the previous post about picture boxes.

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #17

                      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.

                      My blog | My articles | MoXAML PowerToys

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups