1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-05-12 08:00:12 +00:00
3 FS.ListDirectory
boxgaming edited this page 2023-09-25 14:05:54 -05:00

Lists the contents of a directory in the virtual file system.

The returned array contains file descriptor items. Each item has the following properties:

  • name - the name of the file system object
  • type - the type of the file system object (FILE or DIRECTORY)

Syntax

contents = FS.ListDirectory (dirPath$[, listMode&])

Parameters

  • The dirpath$ parameter indicates the path to the directory whose contents should be listed. If not specified, this value will default to the current directory.
  • The optional listMode& parameter indicates whether to include file content, subdirectories or both. If not specified, this value will default to ALL

Examples

Example 1: Display the contents of the current directory.

Import FS From "lib/io/fs.bas"

ReDim contents(0) As String
contents = FS.ListDirectory

Dim i As Integer
For i = 1 To UBound(contents)
    Print i; ": "; contents(i).name;
    If contents(i).type = FS.DIRECTORY Then
        Print, " DIR";
    End If
    Print
Next i

Example 2: Display the file contents of the specified directory.

Import FS From "lib/io/fs.bas"

ReDim contents(0) As String
contents = FS.ListDirectory("/test/img", FS.FILE)

Dim i As Integer
For i = 1 To UBound(contents)
    Print i; ": "; contents(i).name
Next i

See Also

FS.UploadFile
FS.DownloadFile