Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. FileSystemDirectoryEntry

FileSystemDirectoryEntry

TheFileSystemDirectoryEntry interface of theFile and Directory Entries API represents a directory in a file system. It provides methods which make it possible to access and manipulate the files in a directory, as well as to access the entries within the directory.

FileSystemEntry FileSystemDirectoryEntry

Basic concepts

You can create a new directory by callinggetDirectory(). If you want to create subdirectories, create each child directory in sequence. If you try creating a directory using a full path that includes parent directories that do not exist yet, an error is returned. So create the hierarchy by recursively adding a new path after creating the parent directory.

Example

In the following code snippet, we create a directory called "Documents."

js
// Taking care of the browser-specific prefixes.window.requestFileSystem =  window.requestFileSystem || window.webkitRequestFileSystem;window.directoryEntry = window.directoryEntry || window.webkitDirectoryEntry;// …function onFs(fs) {  fs.root.getDirectory(    "Documents",    { create: true },    (directoryEntry) => {      // directoryEntry.isFile === false      // directoryEntry.isDirectory === true      // directoryEntry.name === 'Documents'      // directoryEntry.fullPath === '/Documents'    },    onError,  );}// Opening a file system with temporary storagewindow.requestFileSystem(TEMPORARY, 1024 * 1024 /* 1MB */, onFs, onError);

Instance properties

This interface has no properties of its own, but inherits properties from its parent interface,FileSystemEntry.

Instance methods

This interface inherits methods from its parent interface,FileSystemEntry.

createReader()

Creates aFileSystemDirectoryReader object which can be used to read the entries in this directory.

getDirectory()

Returns aFileSystemDirectoryEntry object representing a directory located at a given path, relative to the directory on which the method is called.

getFile()

Returns aFileSystemFileEntry object representing a file located within the directory's hierarchy, given a path relative to the directory on which the method is called.

removeRecursively()DeprecatedNon-standard

Removes the directory as well as all of its content, hierarchically iterating over its entire subtree of descendant files and directories.

Specifications

Specification
File and Directory Entries API
# api-directoryentry

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp