Platforms to show: All Mac Windows Linux Cross-Platform
/Util/FileList/FileList Recursive
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/FileList/FileList Recursive
This example is the version from Thu, 31th Jul 2019.
Project "FileList Recursive.xojo_binary_project"
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
End Control
Control pbMBS Inherits PushButton
ControlInstance pbMBS Inherits PushButton
EventHandler Sub Action()
dim TheFolder as folderItem
dim t as integer
list.deleteAllRows
TheFolder=SelectFolder
t=ticks
LoadFolderMBS(TheFolder)
t=Ticks-t
self.title=cstr(list.listcount) + " files in "+str(t)+" ticks."
End EventHandler
End Control
Control pbRB Inherits PushButton
ControlInstance pbRB Inherits PushButton
EventHandler Sub Action()
dim TheFolder as folderItem
dim t as integer
list.deleteAllRows
TheFolder=SelectFolder
t=Ticks
LoadFolderRB(TheFolder)
t=ticks-t
self.title=cstr(list.listcount) + " files in "+str(t)+" ticks."
End EventHandler
End Control
Protected Sub LoadFolderMBS(g as FileListMBS)
// we avoid folderitems for speed and go with FileListMBS here
dim list as listbox = self.List // makes access to listbox faster
dim c as integer = g.Count - 1
for i as integer = 0 to c
dim path as string = g.ItemPath(i)
if g.Visible(i) then
dim Name as string = g.Name(i)
if g.Directory(i) then
List.AddRow Name
List.Cell(List.LastIndex,1) = "-"
List.Cell(List.LastIndex,2) = path
dim n as new FileListMBS(g, i)
LoadFolderMBS n
else
List.AddRow Name
List.Cell(List.LastIndex,1) = format(g.LogicalDataLength(i)/1024,"0")+" KB"
List.Cell(List.LastIndex,2) = path
end if
end if
next
End Sub
Protected Sub LoadFolderMBS(f as folderItem)
dim g as new FileListMBS(f)
LoadFolderMBS g
End Sub
Protected Sub LoadFolderRB(f as folderItem)
dim list as listbox = self.List
dim c as integer = f.Count
for i as integer = 1 to c
dim g as FolderItem = f.trueitem(i)
if g <> nil then
if g.Visible then
dim Path as string = g.nativePath
if g.directory then
List.AddRow g.Name
List.Cell(List.LastIndex, 1) = "-"
List.Cell(List.LastIndex, 2) = path
LoadFolderRB(g)
else
List.AddRow g.Name
List.Cell(List.LastIndex, 1) = format(g.length/1024,"0")+" KB"
List.Cell(List.LastIndex, 2) = path
end if
end if
end if
next
End Sub
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project
See also:
The items on this page are in the following plugins: MBS Util Plugin.