My code for populating the list box with filenames is working fine, but now I need to make a slight adjustment. Sometimes my app will create a “garbage” file which needs to be cleaned up before the list is populated.
Deleting the garbage file does work, but it’s still shown in the listbox on first open. Opening the list on the second ocassion works as expected - which does make some sense to me.
However, the garbage file should never be shown in the first place.
This is the code.
[code]
Dim testName As String
listSavedFiles.DeleteAllRows // first clear the previous list
Dim filecount As Integer = myFolder.Count
For i As Integer = 1 To filecount
Dim f As FolderItem = myFolder.Item(i)
If f <> Nil AND f.Name = "garbage.final" Then // first checks, then deletes if garbage file "garbage.final" exists.
f.Delete
MsgBox ("Blank garbage.final file found, but exists no more.")
End If
If f <> Nil AND f.Name.Right(6) = ".final" Then //Only show *.final files in the listbox
//----------------------------------------POPULATE THE LISTBOX-------------
testName = f.Name
listSavedFiles.AddRow(testName)
//----------------------------------------------------------------------------------------
End If
Next[/code]
Some bits of the code were removed for clarity - hopefully not the important bits.
Cheers.