the process cannot access the file '' because it is being used by another process...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #16
    Originally posted by Plater
    Use the .Clone() function on the image.

    Code:
    Bitmap tempbm=new Bitmap("./thumbs/" + filename + "-Thumbnail.jpg"); 
    thumbCell.Value=tempbm.Clone();
    tempbm.Dispose();
    No muss, no fuss
    Did you give this a try? It definitely looks way slicker than what I have, so I tried implementing it... the file handle is still left open. There is a reason for this, it's intended behaviour by the Image class. The only way I've found to get around this is to load it into memory still...

    Please let me know if this worked for you... if it did, I must be doing something wrong.

    Comment

    • HaLo2FrEeEk
      Contributor
      • Feb 2007
      • 404

      #17
      I didn't try it because I don't want to mess with files at all. Like I said, the program uses more memory when downloading the images to files than it does when I download it to a memorystream, so I'd rather use a memorystream.

      I still need help with the example of tlhintoq's suggestion.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #18
        Oh sorry, I was talking to Platter in that particular message. I'm just wondering if he's doing something I'm not to make that work.

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #19
          I still need help with the example of tlhintoq's suggestion.
          Frinny wrote a nice article on creating custom events:


          My own article on C# events can be found here:

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #20
            (Since there no longer seems to be the ability to quote messages)
            Gary: You're saying your file handle is kept open? The .Clone() method should not transfer the open file handle to the new image. But I will double check. I know I was doing the .Clone() to get rid of open file handles, but maybe I did something else to make it work

            Comment

            • GaryTexmo
              Recognized Expert Top Contributor
              • Jul 2009
              • 1501

              #21
              (I noticed that about the quoting thing too.... what happened?)

              Yea, I used the code you had and it left the handle open for me. I tried nulling the object as well as disposing it and still the same.

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #22
                Yea, I see that it keeps it open. My situation was a little different (involved Icon files) and seemed to work for that.

                I just created this and it seemed to work?
                [code=C#]
                private static Bitmap OpenBm(string location)
                {
                Bitmap a = (Bitmap)Bitmap. FromFile(locati on);
                Bitmap b = new Bitmap(a.Width, a.Height, a.PixelFormat);
                b.SetResolution (a.HorizontalRe solution, a.VerticalResol ution);
                //copy any other PropertyItems you may want?
                Graphics gb = Graphics.FromIm age(b);
                gb.DrawImage(a, 0, 0);

                a.Dispose();
                return b;
                }
                [/code]

                Comment

                • GaryTexmo
                  Recognized Expert Top Contributor
                  • Jul 2009
                  • 1501

                  #23
                  Hmmm ok. At that point I think one is as good as the other; the memory streams are working for me so I'll stick with that. Like I said before, I did some reading on the subject and Microsoft intends for this behaviour (though I feel like there should be an option built in).

                  Comment

                  • tlhintoq
                    Recognized Expert Specialist
                    • Mar 2008
                    • 3532

                    #24
                    Originally posted by Plater
                    (Since there no longer seems to be the ability to quote messages)
                    Originally posted by GaryTexmo
                    (I noticed that about the quoting thing too.... what happened?)
                    Select text
                    Copy
                    Hit the quote balloon button
                    Paste
                    *Optionally assign a name to the quote inside the tag

                    Comment

                    • Plater
                      Recognized Expert Expert
                      • Apr 2007
                      • 7872

                      #25
                      Yes yes I know I can type [ quote ] and such, but there used to be a nice reply button

                      Comment

                      • tlhintoq
                        Recognized Expert Specialist
                        • Mar 2008
                        • 3532

                        #26
                        I find it interesting that the quote link still exists in other forums such as the lounge:


                        That indicates that it still exists but has been SET to not be on in the various development forums such as this one. That is truly odd.

                        Comment

                        • GaryTexmo
                          Recognized Expert Top Contributor
                          • Jul 2009
                          • 1501

                          #27
                          I noticed a bit of a change in the appearance of the forums lately and I seem to recall it happened about then. I wonder if a setting got missed in the changeover?

                          Ah, here's the answer... it was intended.


                          But I guess they're looking at putting it back in (yay!).

                          Comment

                          • tlhintoq
                            Recognized Expert Specialist
                            • Mar 2008
                            • 3532

                            #28
                            I add my vote/voice to having it back on.
                            Or maybe on for users>newbie

                            Comment

                            Working...