GetFileSystemEntries Activity
Purpose: This activity gets both files and directories in a specified path. Unlike GetFiles which only returns files, this activity returns all file system entries (both files and directories). You can optionally filter by a search pattern and choose to search only the top directory or all subdirectories.
Input Properties
The directory path to search in. This must be an existing directory that is accessible.
Type: string
Required: Yes
Example: "C:\Data\Documents"
Search pattern for entries (e.g., '*', '*.txt', 'temp*').
Type: string
Default: "*"
Example: "*.txt" for text files, "temp*" for entries starting with "temp"
Note: Use "*" to get all entries, or specify a pattern to filter results.
Search option: 'TopDirectoryOnly' or 'AllDirectories'.
Type: string
Default: "TopDirectoryOnly"
The valid values are:
TopDirectoryOnly- Search only in the specified directory (default)AllDirectories- Search in the specified directory and all subdirectories
Output Properties
Array of file and directory paths as JSON string.
Type: string
Note: Returns a JSON array string like ["C:\\Data\\File1.txt", "C:\\Data\\Folder1"] if successful, an empty JSON array "[]" if no entries are found or if the directory path is empty, or an error message (starting with "Error: ") if an error occurs.
Number of entries found (files and directories combined).
Type: int
Note: Returns the count of entries found if successful, or 0 if no entries are found, if the directory path is empty, or if an error occurs.
Usage Example
Scenario: Get all files and directories in a directory Configuration: - DirectoryPath: "C:\Data\Documents" - SearchPattern: "*" - SearchOption: "TopDirectoryOnly" Result: - Entries: "[\"C:\\\\Data\\\\Documents\\\\File1.txt\", \"C:\\\\Data\\\\Documents\\\\Folder1\"]" - Count: 2 Scenario: Get all entries recursively Configuration: - DirectoryPath: "C:\Data" - SearchPattern: "*" - SearchOption: "AllDirectories" Result: - Entries: "[\"C:\\\\Data\\\\File1.txt\", \"C:\\\\Data\\\\Folder1\", \"C:\\\\Data\\\\Folder1\\\\File2.txt\"]" - Count: 3
Error Handling
Important: The activity handles errors gracefully:
- If
DirectoryPathis null or empty,Entrieswill be set to"[]"andCountwill be 0 - If the directory does not exist (
DirectoryNotFoundException),Entrieswill be set to"[]"andCountwill be 0 - If access is denied (
UnauthorizedAccessException),Entrieswill contain: "Error: Access denied - {exception message}" andCountwill be 0 - If any other exception occurs,
Entrieswill contain: "Error: {exception message}" andCountwill be 0 - The activity does not throw exceptions - errors are indicated in the
Entriesoutput
Always check the Entries output to verify if the operation succeeded. If the string starts with "Error: ", the operation failed. Otherwise, it contains a valid JSON array.
Important Notes
- The DirectoryPath must point to an existing directory that is accessible
- This activity returns both files and directories - use GetFiles if you only need files
- The SearchPattern supports wildcards: "*" matches any characters, "?" matches a single character
- Use SearchOption "AllDirectories" to search recursively through subdirectories
- The Entries output is a JSON array string that can be parsed to get individual paths
- Use the Count output to quickly determine how many entries were found
- Searching with "AllDirectories" may take longer for directories with many subdirectories
Related Activities
- GetFiles - Get only files (not directories)
- GetDirectories - Get only directories (not files)
- GetFileSize - Get size of individual files