title: How to delete files containing string from listbox
body: <p>I want to delete all files in the folder which names can not be found in listbox items. I assume i m missing a counter somewhere, but not really sure how to do this exactly.  </p>
  
  <pre><code>Dim directoryName As String = "Folderimages"
  For Each deleteFile In Directory.GetFiles(directoryName, "*.*",SearchOption.TopDirectoryOnly)
    For Each item In ListBox1.Items
      Dim items As Object = ListBox1.Items
      Dim itemText As String = ListBox1.GetItemText(items)                
      If Not deleteFile.Contains(itemText) Then
        File.Delete(deleteFile)
      End If
    Next
  Next
  </code></pre>