|
-
Mar 8th, 2021, 03:25 PM
#1
Thread Starter
Junior Member
[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
-
Mar 8th, 2021, 04:09 PM
#2
Re: Problem With Deleting Images
Try disposing of the image before deleting.
-
Mar 8th, 2021, 04:20 PM
#3
Thread Starter
Junior Member
Re: Problem With Deleting Images
This seems to be working, at least some of the time. Further testing is indicated. Thanks much!
-
Mar 8th, 2021, 04:27 PM
#4
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|