2.6 KiB
nav-title, title, description
| nav-title | title | description |
|---|---|---|
| file-system How-To | How-To | Examples for using file-system |
File System
Using the file system requires the FileSystem module.
The pre-required fs module is used throughout the following code snippets.
Path
Normalize a Path
Path Join
Concatenate a path to a file by providing multiple path arguments.
Get the Path Separator
Get or Create a File With Path
The following example writes some text to a file created for path. It will create a new file or overwrite an existing file.
Get or Create a Folder With Path
Create
Writing a string to a File
The following example writes some text to a file. It will create a new file or overwrite an existing file.
Get or Create a File
Get or Create a Folder
Read
Reading from a File
The following example writes some text to a file and then reads it back.
Reading/writing binary data from/to a File
Getting the Known Folders
Each app has several well known folders. This is how to access them:
Getting Folder Contents
Getting all files and folders within a folder:
Enumerating Folder Contents
Getting all folder entities in array may be slow with large number of files. Enumerating the folder entities would iterate the files one by one without blocking the UI.
Getting Parent Folder
Getting File Name and Extension
Checking if a File Exists
Checking if a Folder Exists
Update
Renaming a File
Renaming a Folder
Delete
Removing a File
To 'delete', 'remove' or 'unlink' a file use the file's remove method:
Removing a Folder
Clearing the Contents of a Folder
The clear method removes all files within a folder.