S
Sean
Hello all,
I have an application that is using some picture box controls that are being
used to preview jpg files. The jpg files are created on the fly and will be
overwritten when needed. The issue I'm having is that when I release the
picturebox resources, they still seem to be hanging on at the OS level
because I can't delete the file.
Here's a code snippet of what I'm doing:
private void button1_Click(object sender, System.EventArgs e)
{
//check to see if the picturebox has an image already.
if(pictureBox1.Image != null)
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}
if(System.IO.File.Exists("C:\\test.jpg"))
{
System.IO.File.Delete("C:\\test.jpg");
}
//Save the new file with the same name:
wwss.SaveAsJpeg("C:\\test.jpg");
pictureBox1.Image =
Image.FromFile(@"C:\\test.jpg").GetThumbnailImage(136,120,null,new
intPtr());
}
Works first time through every time. The second time the button is clicked,
it goes into the check for image section just fine. No errors, until I get
to deleting the file. If I comment out the pictureBox1.Image =
Image.FromFile... section and trace through this same code, it'll run all
day long deleting the file and saving a new one. So where am I going wrong,
or is this some known issue that I'm not aware of ? Using .NET 1.0
Thanks!
Sean
I have an application that is using some picture box controls that are being
used to preview jpg files. The jpg files are created on the fly and will be
overwritten when needed. The issue I'm having is that when I release the
picturebox resources, they still seem to be hanging on at the OS level
because I can't delete the file.
Here's a code snippet of what I'm doing:
private void button1_Click(object sender, System.EventArgs e)
{
//check to see if the picturebox has an image already.
if(pictureBox1.Image != null)
{
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
}
if(System.IO.File.Exists("C:\\test.jpg"))
{
System.IO.File.Delete("C:\\test.jpg");
}
//Save the new file with the same name:
wwss.SaveAsJpeg("C:\\test.jpg");
pictureBox1.Image =
Image.FromFile(@"C:\\test.jpg").GetThumbnailImage(136,120,null,new
intPtr());
}
Works first time through every time. The second time the button is clicked,
it goes into the check for image section just fine. No errors, until I get
to deleting the file. If I comment out the pictureBox1.Image =
Image.FromFile... section and trace through this same code, it'll run all
day long deleting the file and saving a new one. So where am I going wrong,
or is this some known issue that I'm not aware of ? Using .NET 1.0
Thanks!
Sean