

Or make a not refereced copy of the image when you open it the first time in the app (clone as Acamar says). Possibly you should open the file using filestream then there is no ref maintained. The image with ref to disc is still in the app code you have to dispose it first then dispose the picturebox (if needed). I think if you use imagefromfile then you maintain a reference to the disc file even if you think you delete the file on disc your app still has a ref to it. Show the code for how you open the image originally in the app. To the pictureframe frame in real life) and one is the picture bitmap image (ie canvas painting image in real life). Then do you need to dispose the picturebox control? They are two different things. What line does the error occur on? Why do you pb.dispose? That is the picturebox? You should dispose the image in the picturebox first. MsgBox(strMainImage & vbCr & strThumbName)Īfter these have been executed the flowlayoutpanel is empty, but I still get the error StrMainImage = strThumbName.Replace("_thmb.jpg", ".jpg") 'Action cannot be completed because the file is open in vshost32.exe' I can delete the main image ok.Īnyone know how I can release the file before I try to delete it? Private Sub PBox_Click(ByVal sender As Object, ByVal e As System.EventArgs)ĭim pb As PictureBox = CType(sender, PictureBox)ĭim com As New OleDb.OleDbCommand("DELETE * FROM TBLMEDIA where con)Ĭom.CommandType = OleDbType.VarChar).Value = pb.Tag.ToStringĭim strThumbName As String = pb.Tag.ToString If I try and delete from windows explorer after the message box that displays the file names I get the same: I can delete the links in the database ok but when I try to delete the thumbnail I get an error 'file in use'

but if they check a checkbox it changes the backcolor to show it's highlighted and then asks the user if they want to delete the image. Normally when the user clicks one of the thumbnails in the panel, it just opens the image full screen. I'm using the code below to try to accomplish this task. The application copys the image to an image folder and generates a thumbnail and stores that too in the same folder with the same name but with _thmb on the end of the filename. I've got it inserting images ok but I'm stuck when trying to delete them. I'm using a flowlayout panel to display images that come from links in a database.
