首页指南参考教程
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 51).

Expo FileSystem (next) iconExpo FileSystem (next)

A library that provides access to the local file system on the device.

Android
iOS
tvOS

expo-file-system provides access to a file system stored locally on the device.

Installation

Terminal
npx expo install expo-file-system

If you are installing this in an existing React Native app (bare workflow), start by installing expo in your project. Then, follow the additional instructions as mentioned by library's README under "Installation in bare React Native projects" section.

Usage

API

Classes

Android
iOS
tvOS

Directory

Type: Class extends FileSystemDirectory

Directory Properties

Android
iOS
tvOS

path

Type: string

Represents the directory path.

Directory Methods

Android
iOS
tvOS

create()

Creates a directory.

Returns:

void

Android
iOS
tvOS

delete()

Deletes a directory.

Returns:

void

Android
iOS
tvOS

exists()

Checks if a directory exists.

Returns:

boolean

true if the directory exists, false otherwise.

Android
iOS
tvOS

File

Type: Class extends FileSystemFile

File Properties

Android
iOS
tvOS

path

Type: string

Represents the file path.

File Methods

Android
iOS
tvOS

create()

Creates a file.

Returns:

void

Android
iOS
tvOS

delete()

Deletes a file.

Returns:

void

Android
iOS
tvOS

exists()

Checks if a file exists.

Returns:

boolean

true if the file exists, false otherwise.

Android
iOS
tvOS

text()

Retrieves text from the file.

Returns:

string

The contents of the file as string.

Android
iOS
tvOS

write(content)

NameTypeDescription
contentstring

The content to write into the file.


Writes content to the file.

Returns:

void

Methods

Android
iOS
tvOS

FileSystem Next.write(file, contents)

NameType
fileFile
contentsstring

Returns:

Promise<void>

Expo 中文网 - 粤ICP备13048890号