Hi all,
I’m trying to create a form (frmFileList) containing a window that displays a list of files contained in a specified path, with the option to select them using checkboxes or open them. (like Shell Explorer)
This is essentially what an ActiveX program called Fileview does.
I wanted to see if I could achieve the same goal using Xojo objects.
To do this, I used a Listbox.
The frmFileList form is launched from a button object whose MouseDown event contains this code.
Var f As FolderItem = SpecialFolder.Desktop.Child(app.pk_corbeta)
If f.Exists And f.IsFolder Then
Var dlg As New frmFileListdlg.LoadFiles(f)
dlg.ShowModal
Else
MessageBox(“The specified folder does not exist.”+chr(13)+app.pk_corbeta)
End If
app.pk_corbeta is a public variable with the path to the folder on the server.
The LoadFiles method contains this code:
ListBox1.RemoveAllRows
If folder = Nil Or Not folder.Exists Or Not folder.IsFolder Then
MessageBox(“Invalid folder.”)
Return
End If
BaseFolder = folder
Var count As Integer = folder.Count
For i As Integer = 0 To count - 1
Var item As FolderItem = folder.ChildAt(i)
If item <> Nil And item.Exists And Not item.IsFolder Then
ListBox1.AddRow(item.Name)
End If
Next
The form has a public property called BaseFolder of type FolderItem.
What happens is that if the path provided doesn’t end with a backslash, it tells me the folder wasn’t found, while if I end it with a backslash, it shows me a list of files on my client’s desktop.
Can anyone tell me where I’m going wrong?