Skip to content

ReadDir()

ts
ReadDir(path: string, sortBy: string, sortDir: string): respDir;

Reads the contents of a directory in the target file-system or object storage, returning information about the files and subdirectories it contains.

Parameters

ParameterTypeExplanation
pathstringThe fully qualified root-based directory path to list (e.g., /data or C:\\Data)
sortByDirSortByOne of: SortByNameDirsFirst, SortByName, SortBySize, SortByTime
sortDirDirSortDirOne of: SortAsc (ascending), SortDesc (descending)

Returns a respDir object.

Example

ts
var vfs = GetCurrentVFS();
if (vfs != null) {
    var resp = vfs.ReadDir("/data", SortByNameDirsFirst, SortAsc);
    if (resp.Ok()) {
        Log(JSON.stringify(resp.Infos()));
    } else {
        Log(resp.ErrorMsg());
    }
} else {
    Log("VFS was null");
}