-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: shashijeevan
Message 2 in Discussion
HI,
You getting this exception because your pictureBox still holds reference to the
original Image File handle.
Here is one way to solve this problem. This creates a temporary Image and copies the
creates using FileStream.
Note: Image Closing won't work here.private void button2_Click(object sender,
System.EventArgs e){try{//Open or create fileFileStream fs = new FileStream(imgPath,
FileMode.OpenOrCreate, FileAccess.Write);//create image//Close filestreamfs.Close();fs
= null;}catch(Exception exp){MessageBox.Show(exp.StackTrace);}//Create Image from the
file.Image img = Image.FromFile(imgPath); //Create temporary imageBitmap temp = new
Bitmap(img.Width, img.Height);//Get the graphics of the temporary imageGraphics g =
Graphics.FromImage(temp); //copy the imageg.DrawImage(img, 0, 0);//dispose the
original. this closes open file handles.img.Dispose();//dispose the previous temporary
image (Assuming its initialized to null.if(pictureBox1.Image !=
null){pictureBox1.Image.Dispose();pictureBox1.Image=null;}//set the Picture box image
to the temporary copy of the image.pictureBox1.Image = temp;}
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]