emblewembl
Programmer
I have a windows form which shows a list of images in pictureBoxes on a panel on 'tabPage1' using this code:
I then go to 'tabPage2' and can edit some of these images - once i have edited the selected image the changes are saved but I get this error message:
This suggests to me that I am not clearing the picture box on tabPage1 properly or something as it seems to be still in use. When I leave tabPage1 I 'clean up' the panel using this code:
but I am not sure how to clean up the picturebox and 'release' the image file. Can anyone help?!
i love chocolate
Code:
PictureBox pb = new PictureBox();
pb.Image = Image.FromFile(fileName);
pb.BorderStyle = BorderStyle.FixedSingle;
pb.BackColor = Color.White;
pb.Name = "pbI" + addimgCount;
pb.Width = 125;
pb.Height = 130;
pb.SizeMode = PictureBoxSizeMode.CenterImage;
I then go to 'tabPage2' and can edit some of these images - once i have edited the selected image the changes are saved but I get this error message:
Code:
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll
Additional information: The process cannot access the file "c:\Documents and Settings\E\My Documents\Visual Studio Projects\jS\ExImgs\Jpg\haydo\141001.jpg" because it is being used by another process.
This suggests to me that I am not clearing the picture box on tabPage1 properly or something as it seems to be still in use. When I leave tabPage1 I 'clean up' the panel using this code:
Code:
p.Controls.Clear();
but I am not sure how to clean up the picturebox and 'release' the image file. Can anyone help?!
i love chocolate