好的,我在遍历项目列表框并根据文件系统观察程序删除它们时遇到问题。
用户在文本框中输入数值,我将它们添加到列表框中。
Listbox1.Items.Add(Textbox1.Text)
在这里,我当前是如何遍历列表框项目并触发 msgbox 以进行测试的。
Public Sub CheckCreatedPDFs()
For i As Integer = 0 To ListBox1.Items.Count - 1
Dim Watcher As New FileSystemWatcher()
Watcher.Path = "C:\Temp\"
Watcher.NotifyFilter = (NotifyFilters.Attributes)
Watcher.Filter = ListBox1.Items(i) + ".pdf"
AddHandler Watcher.Changed, AddressOf OnChanged
Watcher.EnableRaisingEvents = True
Next i
End Sub
Private Sub OnChanged(source As Object, e As FileSystemEventArgs)
' Specify what is done when a file is created.
MsgBox("SPACE RESERVED FOR REMOVING LISTBOX ITEMS")
End Sub
有关如何删除这些项目的任何建议?谢谢!