### List Folders within a Folder

This example lists the folders within a folder (directory) (requires the JavaObject library) - Class java.io.File.
Option 1 using JavaObject
'Example of listing the file & folders from the dirapp folder
`Sub ListFolders
Dim l As List = File.ListFiles(File.DirApp)
For i = 0 To l.Size - 1
Log(l.Get(i) & " = Folder: " & isDir(l.Get(i)))
Next
End Sub`
'Check if a file is a folder
'Return true if file is folder
`Sub isDir(f As String) As Boolean
Dim fileO As JavaObject
fileO.InitializeNewInstance("java.io.File", Array As Object(f))
Return fileO.RunMethod("isDirectory", Null)
End Sub`
Option 2 using File
`Sub AppStart (Args() As String)
Log(ListFolders("c:\temp"))
End Sub`
`Sub ListFolders(folder As String) As List
Dim folders As List
folders.Initialize
For Each f As String In File.ListFiles(folder)
If File.IsDirectory(folder, f) Then folders.Add(File.Combine(folder,f))
Next
Return folders
End Sub`

Changed: , Category: Files, File: T6C193M1383.htm, ID: 1383