Skip to content

$ps.file.getDirectoryList

Overview

Use "$ps.file" in "Server Script" to get a list of directory names in a specified directory.

Prerequisites

DisableServerScriptFile in "Script.json" must be set to false.

Syntax

$ps.file.getDirectoryList(section, path)

Parameters

Parameter Type Required Description
section string Yes Section name. For details about sections, see "About Sections" in "$ps.file".
path string Yes Directory name. For both Windows and Linux, the directory separator is "/".

Return Value

Returns an array of directory name strings.

Exceptions

If an exception occurs in C#, the exception class name and error message are placed in the Error object in the server script to raise an exception.

Usage Examples

The following example gets a list of directory names in a specified directory in the web server and outputs the results to a log.

JavaScript
const lists = $ps.file.getDirectoryList('test_data','parts');
context.Log('listCnt='+lists.length);
for (const element of lists) {
context.Log('list='+element);
}

Supported Versions

Supported versions Body
1.4.12.0 and later Added function