1
Guys I’m using the following code to grab images from a directory and put 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 command below 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 error message saying that the file is already open and so cannot be closed.
So my question is how to remove the image so I can delete it?
It was bad for the code starting now, but this code is with a problem for min. The name of the images change but the images remain the same, I made a test with 3 images and the name changed but they were with the same "cover".
– Lucas Pedro
I edited the answer. The counter was inside the looping
– Eduardo Oliveira
When I delete for example the first image, it is deleted from pc, but not from listview. The name corresponding to the image is gone, but a different image is deleted from listview.
– Lucas Pedro
I edited the answer, you need to clear your image and listview.
– Eduardo Oliveira