0
Answer

problem copying image

Ask a question
x _sanctus

x _sanctus

18y
1.7k
1
I create application where user change their picture i have a PictureBox foto where user's old image viewed. when the user upload new image the new image will be resized, viewed in the picture box and overwrite the old image (the filename is the same with the old one) The problem is i cannot the old picture because it said that it is still used, therefore i got exception "generic GDI+ error". But when the user uploaded the image for the 2nd time there is no exception. How can i solve this problem?? thisis the procedure to upload the image private void openFotoDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { try { System.Drawing.Size size=new Size(90,90); Image tempImage; tempImage=new Bitmap(Image.FromStream(openFotoDialog.OpenFile()),size); this.foto.Image=tempImage; //if(File.Exists(this.picFolderPath+Login.userNim+".jpeg")) //File.Delete(this.picFolderPath+Login.userNim+".jpeg"); tempImage.Save(this.picFolderPath+Login.userNim+".jpeg",ImageFormat.Jpeg); this.statusProfil.Text="foto uploaded"; } catch(){ } }