Results 1 to 4 of 4

Thread: [RESOLVED] Problem With Deleting Images

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2020
    Posts
    12

    Resolved [RESOLVED] Problem With Deleting Images

    Hey Folks,

    Using VS2019 16.9. I've been building an image viewer. Without dumping the code on you (there's a fair amount of it), I'm having a problem deleting images, as I want to have a "delete" function in the viewer. The problem seems to be that my own code is making use of the image in such a way as to lock the file. When I try to delete an image, I get error messages about the file being in use.

    What the code does is load a file into a bitmap object so it can check the height and width. Based on that, a picturebox's SizeMode property is set appropriately, then the picturebox's Image property is set to the bitmap. All that works fine, but it seems to lock the bitmap. I tried using bitmap.Dispose() after setting the image property of the picturebox, but when I do that the picturebox displays an error image. So that's out. The bitmap object is itself global, as it has to be used in multiple locations.

    It occurred to me that loading an unrelated image into the bitmap and thence into the picturebox might fix it, but alas, no. Has anyone got any bright ideas?

    TIA,

    Lars

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,764

    Re: Problem With Deleting Images

    Try disposing of the image before deleting.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2020
    Posts
    12

    Re: Problem With Deleting Images

    This seems to be working, at least some of the time. Further testing is indicated. Thanks much!

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2020
    Posts
    12

    Re: Problem With Deleting Images

    Yes, this is working. Thanks much, once again!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width