require('uxp').storage.Folder
Represents a folder on a file system. You'll never instantiate this directly, but will get it by calling FileSystemProvider.getTemporaryFolder, FileSystemProvider.getFolder, or via Folder.getEntries.
isFolder
Indicates that this instance is a folder. Useful for type checking.
getEntries()
Returns an array of entries contained within this folder.
Returns: Promise<Array<Entry>> - The entries within the folder.
Example
const entries = await aFolder.getEntries();
const allFiles = entries.filter(entry => entry.isFile);
createEntry(name, options)
Creates an entry within this folder and returns the appropriate instance.
stringanySymboltypes.filebooleanfalsetrue, the create attempt can overwrite an existing fileReturns: Promise<File | Folder> - the created entry
Example
const myNovel = await aFolder.createEntry("mynovel.txt");
Example
const catImageCollection = await aFolder.createEntry("cats", {type: types.folder});
createFile(name, options)
Creates a File Entry object within this folder and returns the appropriate instance. Note that this method just create a file entry object and not the actual file on the disk. The file actually gets created when you call for eg: write method on the file entry object.
stringanybooleanfalsetrue, the create attempt can overwrite an existing fileReturns: Promise<File> - the created file entry
Example
const myNovelTxtFile = await aFolder.createFile("mynovel.txt");
createFolder(name)
Creates a Folder within this folder and returns the appropriate instance.
stringReturns: Promise<Folder> - the created folder entry object
Example
const myCollectionsFolder = await aFolder.createFolder("collections");
getEntry(filePath)
Gets an entry from within this folder and returns the appropriate instance.
stringReturns: Promise<File | Folder> - the fetched entry.
Example
const myNovel = await aFolder.getEntry("mynovel.txt");
renameEntry(entry, newName, options)
Renames an entry to a new name.
Entrystringanybooleanfalsetrue, renaming can overwrite an existing entryReturns: Promise<void>
Example
await myNovels.rename(myNovel, "myFantasticNovel.txt");
isFolder(entry): boolean
Checks if an entry is a folder. Safe to use if entry might be null or undefined. Useful for type checking.
Returns: boolean - if true, the entry is a folder
any