|
| 1 | +## File Properties |
1 | 2 |
|
2 | | -**API Reference for the** [File System Module](https://docs.nativescript.org/api-reference/modules/_file_system_.html) |
| 3 | +| Name | Type | Description | |
| 4 | +|----------|---------|----------------| |
| 5 | +| `extension` | `string` | Gets the extension of the file. | |
| 6 | +| `isLocked` | `boolean` | Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running. | |
| 7 | +| `lastModified` | `Date` | Gets the Date object specifying the last time this entity was modified. | |
| 8 | +| `name` | `string` | Gets the name of the entity. | |
| 9 | +| `parent` | `Folder` | Gets the Folder object representing the parent of this entity. Will be null for a root folder like Documents or Temporary. This property is readonly. | |
| 10 | +| `path` | `string` | Gets the fully-qualified path (including the extension for a File) of the entity.| |
| 11 | +| `size` | `number` | Gets the size in bytes of the file. | |
3 | 12 |
|
4 | | -**API Reference for the** [File Class](https://docs.nativescript.org/api-reference/classes/_file_system_.file.html) |
| 13 | +## File Methods |
5 | 14 |
|
6 | | -**API Reference for the** [FileSystemEntity Class](https://docs.nativescript.org/api-reference/classes/_file_system_.filesystementity.html) |
| 15 | +| Name | Return Type | Description | |
| 16 | +|----------|---------|----------------| |
| 17 | +| `read` | `Promise<any>` | Reads the binary content of the file asynchronously. | |
| 18 | +| `readSync(onError?: function)` | `any` | Reads the binary content of the file synchronously. | |
| 19 | +| `readText(encoding?: string)` | `Promise<string>` | Reads the content of the file as a string using the specified encoding (defaults to UTF-8). | |
| 20 | +| `readTextSync(onError?: function, encoding?: string)` | `string` | Reads the content of the file as a string synchronously, using the specified encoding (defaults to UTF-8). | |
| 21 | +| `remove` | `void` | Removes (deletes) the current Entity from the file system. | |
| 22 | +| `removeSync(onError?: function)` | `void` | Removes (deletes) the current Entity from the file system synchronously.| |
| 23 | +| `rename(newName: string)` | `Promise<any>` | Renames the current entity using the specified name. | |
| 24 | +| `renameSync(newName: string, onError?: function)` | `void` | Renames the current entity synchronously, using the specified name. | |
| 25 | +| `write(newName: string)` | `Promise<void>` | Writes the provided binary content to the file. | |
| 26 | +| `writeSync(newName: string, onError?: function)` | `void` | Writes the provided binary content to the file synchronously. | |
| 27 | +| `writeText(encoding?: string)` | `Promise<string>` | Writes the content of the file as a string using the specified encoding (defaults to UTF-8). | |
| 28 | +| `writeTextSync(onError?: function, encoding?: string)` | `string` | Writes the content of the file as a string synchronously, using the specified encoding (defaults to UTF-8). | |
| 29 | +| `exists(path: string)` | `boolean` | Checks whether a File with the specified path already exists. | |
| 30 | +| `fromPath(path: string)` | `File` | Gets or creates a File entity at the specified path. | |
| 31 | + |
| 32 | +## Folder Properties |
| 33 | + |
| 34 | +| Name | Type | Description | |
| 35 | +|----------|---------|----------------| |
| 36 | +| `isKnown` | `boolean` | Determines whether this instance is a KnownFolder (accessed through the KnownFolders object). | |
| 37 | +| `lastModified` | `Date` | Gets the Date object specifying the last time this entity was modified. | |
| 38 | +| `name` | `string` | Gets the name of the entity. | |
| 39 | +| `parent` | `Folder` | Gets the Folder object representing the parent of this entity. Will be null for a root folder like Documents or Temporary. This property is readonly. | |
| 40 | +| `path` | `string` | Gets the fully-qualified path (including the extension for a File) of the entity.| |
| 41 | + |
| 42 | +## Folder Methods |
| 43 | + |
| 44 | +| Name | Return Type | Description | |
| 45 | +|----------|---------|----------------| |
| 46 | +| `clear` | `Promise<any>` | Deletes all the files and folders (recursively), contained within this Folder. | |
| 47 | +| `clearSync(onError?: function)` | `void` | Deletes all the files and folders (recursively), contained within this Folder synchronously. | |
| 48 | +| `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. | |
| 49 | +| `eachEntity(onEntity: function)` | `any` | Enumerates all the top-level FileSystem entities residing within this folder. | |
| 50 | +| `getEntities` | `Promise<Array<FileSystemEntity>>` | Gets all the top-level entities residing within this folder. | |
| 51 | +| `getEntitiesSync(onError?: function)` | `Array<FileSystemEntity>` | Gets all the top-level entities residing within this folder synchronously | |
| 52 | +| `getFile(name: string)` | `File` | Gets or creates a File entity with the specified name within this Folder. | |
| 53 | +| `getFolder(name: string)` | `Folder` | Gets or creates a Folder entity with the specified name within this Folder. | |
| 54 | +| `remove` | `Promise<any>` | Removes (deletes) the current Entity from the file system. | |
| 55 | +| `removeSync` | `removeSync(onError?: function)` | Removes (deletes) the current Entity from the file system synchronously. | |
| 56 | + |
| 57 | +## knownFolders Methods |
| 58 | + |
| 59 | +| Name | Return Type | Description | |
| 60 | +|----------|---------|----------------| |
| 61 | +| `currentApp` | `Folder` | Gets the root folder for the current application. This Folder is private for the application and not accessible from Users/External apps. iOS - this folder is read-only and contains the app and all its resources. | |
| 62 | +| `documents` | `Folder` | Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. | |
| 63 | +| `temp` | `Folder` | Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. | |
| 64 | + |
| 65 | +## path Methods |
| 66 | + |
| 67 | +| Name | Return Type | Description | |
| 68 | +|----------|---------|----------------| |
| 69 | +| `join(...paths: string[])` | `string` | Joins all the provided string components, forming a valid and normalized path. | |
| 70 | +| `normalize(path: string)` | `string` | Normalizes a path, taking care of occurrances like ".." and "//". | |
| 71 | + |
| 72 | + |
| 73 | +## API References |
| 74 | + |
| 75 | +| Name | Type | |
| 76 | +|----------|---------| |
| 77 | +| [tns-core-modules/file-system](https://docs.nativescript.org/api-reference/modules/_file_system_.html) | `Module` | |
| 78 | +| [FileSystem](https://docs.nativescript.org/api-reference/classes/_file_system_.file.html) | `Class` | |
| 79 | +| [FileSystemEntity](https://docs.nativescript.org/api-reference/classes/_file_system_.filesystementity.html) | `Class` | |
| 80 | +| [Folder](https://docs.nativescript.org/api-reference/classes/_file_system_.folder.html) | `Class` | |
| 81 | +| [knownFolders](https://docs.nativescript.org/api-reference/modules/_file_system_.knownfolders) | `Module` | |
| 82 | +| [path](https://docs.nativescript.org/api-reference/modules/_file_system_.path) | `Module` | |
7 | 83 |
|
8 | | -**API Reference for the** [Folder Class](https://docs.nativescript.org/api-reference/classes/_file_system_.folder.html) |
|
0 commit comments