8.6 Released with 🥽 visionOS support and more!
Check it out
Represents a Folder (directory) entity on the file system.

Summary

Constructors

constructor

new Folder(): Folder
inherited from constructor
Returns Folder

Properties

isKnown

isKnown: boolean
Determines whether this instance is a KnownFolder (accessed through the KnownFolders object).

Methods

clear

clear(): Promise<any>
Deletes all the files and folders (recursively), contained within this Folder.
Returns Promise<any>

clearSync

clearSync(onError?: (error: any) => void): void
Deletes all the files and folders (recursively), contained within this Folder synchronously.
Parameter Default Description
onError
(error: any) => void

An optional function to be called if some error occurs.

Returns void

contains

contains(name: string): boolean
Checks whether this Folder contains an Entity with the specified name. The path of the folder is added to the name to resolve the complete path to check for.
Parameter Default Description
name
string

The name of the entity to check for.

Returns boolean

eachEntity

eachEntity(onEntity: (entity: FileSystemEntity) => boolean): any
Enumerates all the top-level FileSystem entities residing within this folder.
Parameter Default Description
onEntity
(entity: FileSystemEntity) => boolean

A callback that receives the current entity. If the callback returns false this will mean for the iteration to stop.

Returns any

getEntities

getEntities(): Promise<FileSystemEntity[]>
Gets all the top-level entities residing within this folder.
Returns Promise<FileSystemEntity[]>

getEntitiesSync

getEntitiesSync(onError?: (error: any) => any): FileSystemEntity[]
Gets all the top-level entities residing within this folder synchronously.
Parameter Default Description
onError
(error: any) => any

An optional function to be called if some error occurs.

Returns FileSystemEntity[]

getFile

getFile(name: string): File
Gets or creates a File entity with the specified name within this Folder.
Parameter Default Description
name
string

The name of the file to get/create.

Returns File

getFolder

getFolder(name: string): Folder
Gets or creates a Folder entity with the specified name within this Folder.
Parameter Default Description
name
string

The name of the folder to get/create.

Returns Folder

exists

Static
exists(path: string): boolean
Checks whether a Folder with the specified path already exists.
Parameter Default Description
path
string

The path to check for.

Returns boolean

fromPath

Static
fromPath(path: string): Folder
Gets or creates a Folder entity at the specified path.
Parameter Default Description
path
string

The path to get/create the folder at.

Returns Folder
Next
Font