I'm using the following code to grab images from a directory and put it in a ListView:
For Each arquivos In FileIO.FileSystem.GetFiles(caminho, FileIO.SearchOption.SearchAllSubDirectories, "*.png")
Dim nome_arq As String = System.IO.Path.GetFileNameWithoutExtension(arquivos)
imagem.Images.Add(Image.FromFile(arquivos))
ListView1.LargeImageList = imagem
ListView1.Items.Add(nome_arq, contador)
And I wanted to use the below command to delete the image that was open in ListView1
My.Computer.FileSystem.DeleteFile(dicionario(posicao),
FileIO.UIOption.OnlyErrorDialogs,
FileIO.RecycleOption.SendToRecycleBin,
FileIO.UICancelOption.DoNothing)
The problem is that I get the error message saying that the file is already open and therefore can not be closed.
So my question is how do I remove the image so I can delete it?