I am having an issue where I try to delete a file and get the error message that it is already in use. I can not seem to figure out what is currently using the file. Maybe someone here has an idea.
The commented line is where the problem occurs. I added the line which clears the imagelist thinking that may solve the problem but no joy.Code:ImageList2.Images.Clear() Dim Dq AsInteger = 0 For Dq = 0 To DeleteQue.Count - 1 For X = 0 To UBound(TmpAttached) If DeleteQue.Item(Dq) = TmpAttached(X) Then Try 'File.Delete(OutPutFolder & "\" & txtAuction.Text & "\" & DeleteQue.Item(Dq)) TmpAttached(X) = "" TmpThumb(X) = "" Catch ex As Exception MsgBox("Unable to remove attached file " & DeleteQue(Dq) & vbCrLf & ex.Message) EndTry EndIf Next Next
The only place I can think of that the file is used is in the image list and the listview. At the point where the code above executes the files where the delete will apply have already been removed from the listview and as far as I can tell should only exist in the image list where they were added using the following code
I would have thought that clearing the imagelist would have released the file. Any ideas?Code:For X = 0 To UBound(FileNames) PG.ProgressBar1.Value += 1 myImage = Image.FromFile(OutPutFolder & "\" & txtAuction.Text & "\" & FileNames(X)) ImageList2.Images.Add(myImage) myImage=nothing Next




Reply With Quote