9.0 Released! → Native ESM runtimes 🚀, Vite support ⚡️, multi-window apps and more...
Read Announcement

Defined in: file-system/index.d.ts:89

Represents a File entity on the file system.

Extends

Constructors

Constructor

ts
new File(): File;

Returns

File

Inherited from

FileSystemEntity.constructor

Properties

extension

ts
extension: string;

Defined in: file-system/index.d.ts:103

Gets the extension of the file.


isLocked

ts
isLocked: boolean;

Defined in: file-system/index.d.ts:113

Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running.


lastModified

ts
lastModified: Date;

Defined in: file-system/index.d.ts:31

Gets the Date object specifying the last time this entity was modified.

Inherited from

FileSystemEntity.lastModified


name

ts
name: string;

Defined in: file-system/index.d.ts:36

Gets the name of the entity.

Inherited from

FileSystemEntity.name


parent

ts
parent: Folder;

Defined in: file-system/index.d.ts:48

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.

Inherited from

FileSystemEntity.parent


path

ts
path: string;

Defined in: file-system/index.d.ts:41

Gets the fully-qualified path (including the extension for a File) of the entity.

Inherited from

FileSystemEntity.path


size

ts
size: number;

Defined in: file-system/index.d.ts:108

Gets the size in bytes of the file.


android

ts
readonly static android: Android;

Defined in: file-system/index.d.ts:90


ios

ts
readonly static ios: iOS;

Defined in: file-system/index.d.ts:92

Methods

append()

ts
append(content: any): Promise<void>;

Defined in: file-system/index.d.ts:134

Appends the provided binary content to the file.

Parameters

ParameterTypeDescription
contentanyThe binary content to be saved to the file.

Returns

Promise<void>


appendSync()

ts
appendSync(content: any, onError?: (error: any) => any): void;

Defined in: file-system/index.d.ts:141

Appends the provided binary content to the file synchronously.

Parameters

ParameterTypeDescription
contentanyThe binary content to be saved to the file.
onError?(error: any) => anyAn optional function to be called if some IO-error occurs.

Returns

void


appendText()

ts
appendText(content: string, encoding?: string): Promise<any>;

Defined in: file-system/index.d.ts:120

Appends the provided string to the file, using the specified encoding (defaults to UTF-8).

Parameters

ParameterTypeDescription
contentstringThe content to be saved to the file.
encoding?stringAn optional value specifying the preferred encoding (defaults to UTF-8).

Returns

Promise<any>


appendTextSync()

ts
appendTextSync(
   content: string, 
   onError?: (error: any) => any, 
   encoding?: string): void;

Defined in: file-system/index.d.ts:128

Appends the provided string to the file synchronously, using the specified encoding (defaults to UTF-8).

Parameters

ParameterTypeDescription
contentstringThe content to be saved to the file.
onError?(error: any) => anyAn optional function to be called if some IO-error occurs.
encoding?stringAn optional value specifying the preferred encoding (defaults to UTF-8).

Returns

void


copy()

ts
copy(dest: string): Promise<boolean>;

Defined in: file-system/index.d.ts:148

Copies a file to a given path.

Parameters

ParameterTypeDescription
deststringThe path to the destination file. Returns a Promise with a boolean.

Returns

Promise<boolean>


copySync()

ts
copySync(dest: string, onError?: (error: any) => any): any;

Defined in: file-system/index.d.ts:156

Copies a file to a given path.

Parameters

ParameterTypeDescription
deststringThe path to the destination file.
onError?(error: any) => any(optional) A callback function to use if any error occurs. Returns a Promise with a boolean.

Returns

any


read()

ts
read(): Promise<any>;

Defined in: file-system/index.d.ts:181

Reads the binary content of the file asynchronously.

Returns

Promise<any>


readSync()

ts
readSync(onError?: (error: any) => any): any;

Defined in: file-system/index.d.ts:187

Reads the binary content of the file synchronously.

Parameters

ParameterTypeDescription
onError?(error: any) => anyAn optional function to be called if some IO-error occurs.

Returns

any


readText()

ts
readText(encoding?: string): Promise<string>;

Defined in: file-system/index.d.ts:169

Reads the content of the file as a string using the specified encoding (defaults to UTF-8).

Parameters

ParameterTypeDescription
encoding?stringAn optional value specifying the preferred encoding (defaults to UTF-8).

Returns

Promise<string>


readTextSync()

ts
readTextSync(onError?: (error: any) => any, encoding?: string): string;

Defined in: file-system/index.d.ts:176

Reads the content of the file as a string synchronously, using the specified encoding (defaults to UTF-8).

Parameters

ParameterTypeDescription
onError?(error: any) => anyAn optional function to be called if some IO-error occurs.
encoding?stringAn optional value specifying the preferred encoding (defaults to UTF-8).

Returns

string


remove()

ts
remove(): Promise<any>;

Defined in: file-system/index.d.ts:53

Removes (deletes) the current Entity from the file system.

Returns

Promise<any>

Inherited from

FileSystemEntity.remove


removeSync()

ts
removeSync(onError?: (error: any) => any): void;

Defined in: file-system/index.d.ts:58

Removes (deletes) the current Entity from the file system synchronously.

Parameters

ParameterType
onError?(error: any) => any

Returns

void

Inherited from

FileSystemEntity.removeSync


rename()

ts
rename(newName: string): Promise<any>;

Defined in: file-system/index.d.ts:64

Renames the current entity using the specified name.

Parameters

ParameterTypeDescription
newNamestringThe new name to be applied to the entity.

Returns

Promise<any>

Inherited from

FileSystemEntity.rename


renameSync()

ts
renameSync(newName: string, onError?: (error: any) => any): void;

Defined in: file-system/index.d.ts:70

Renames the current entity synchronously, using the specified name.

Parameters

ParameterTypeDescription
newNamestringThe new name to be applied to the entity.
onError?(error: any) => any-

Returns

void

Inherited from

FileSystemEntity.renameSync


write()

ts
write(content: any): Promise<void>;

Defined in: file-system/index.d.ts:208

Writes the provided binary content to the file.

Parameters

ParameterTypeDescription
contentanyThe binary content to be saved to the file.

Returns

Promise<void>


writeSync()

ts
writeSync(content: any, onError?: (error: any) => any): void;

Defined in: file-system/index.d.ts:215

Writes the provided binary content to the file synchronously.

Parameters

ParameterTypeDescription
contentanyThe binary content to be saved to the file.
onError?(error: any) => anyAn optional function to be called if some IO-error occurs.

Returns

void


writeText()

ts
writeText(content: string, encoding?: string): Promise<any>;

Defined in: file-system/index.d.ts:194

Writes the provided string to the file, using the specified encoding (defaults to UTF-8).

Parameters

ParameterTypeDescription
contentstringThe content to be saved to the file.
encoding?stringAn optional value specifying the preferred encoding (defaults to UTF-8).

Returns

Promise<any>


writeTextSync()

ts
writeTextSync(
   content: string, 
   onError?: (error: any) => any, 
   encoding?: string): void;

Defined in: file-system/index.d.ts:202

Writes the provided string to the file synchronously, using the specified encoding (defaults to UTF-8).

Parameters

ParameterTypeDescription
contentstringThe content to be saved to the file.
onError?(error: any) => anyAn optional function to be called if some IO-error occurs.
encoding?stringAn optional value specifying the preferred encoding (defaults to UTF-8).

Returns

void


exists()

ts
static exists(path: string): boolean;

Defined in: file-system/index.d.ts:98

Checks whether a File with the specified path already exists.

Parameters

ParameterTypeDescription
pathstringThe path to check for.

Returns

boolean


fromPath()

ts
static fromPath(path: string, copy?: boolean): File;

Defined in: file-system/index.d.ts:163

Gets or creates a File entity at the specified path.

Parameters

ParameterTypeDescription
pathstringThe path to get/create the file at.
copy?booleanAn optional value when set, copies the content-uri to a temp file enabling the legacy behaviour

Returns

File