PictureBox leaving filehandle open

J

Jeff Williams

I have a picture (jpg) displaying in a picture box but I find that the
file handle is still open to the image on disk.

I think I need the following to happen

1. Load image from file on disk
2. Copy the loaded image to another object.
3. Close the file on disk
4. Display the image in the picture box as a thumbnail.
5. Allow user to rotate image if necessary by reloading the file
6. Save image back to disk as the same file name

Am I on the right track and if so how do I achieve option 2.

Regards
Jeff
 
N

Nicholas Paldino [.NET/C# MVP]

Jeff,

You don't need to do all that. How are you loading the image? If
anything, create the FileStream yourself to load into the Bitmap object,
load the file, and then associate it with the picture box. If I recall
correctly, the from file methods (or whatever they are called) open the file
for exclusive access and don't let it go until the picturebox is disposed of
(or rather the Bitmap instance the picturebox conjures up to show the
picture).

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top