这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

FileSystemFileEntry 接口在 文件系统 API represents a file in a file system. It offers properties describing the file's attributes, as well as the file() method, which creates a File object that can be used to read the file.

特性

继承其父级接口特性, FileSystemEntry , but has no properties unique to this interface.

方法

file()
创建新的 File 对象可以用于读取文件。

过时方法

createWriter()
创建新的 FileWriter object which allows writing to the file represented by the file system entry.

基本概念

要将内容写入文件,创建 FileWriter object by calling createWriter() . To read a file, obtain a File object representing its contents by calling file() .

范例

The following code creates an empty file called " log.txt" (if it doesn't exist) and fills it with the text "Meow". Inside the success callback, event handlers are set up to handle the error error and writeend events. The text data is written to the file by creating a blob, appending text to it, and passing the blob to FileWriter.write() .

function onInitFs(fs) {
  fs.root.getFile('log.txt', {create: true}, function(fileEntry) {
    // Create a FileWriter object for our FileSystemFileEntry (log.txt).
    fileEntry.createWriter(function(fileWriter) {
      fileWriter.onwriteend = function(e) {
        console.log('Write completed.');
      };
      fileWriter.onerror = function(e) {
        console.log('Write failed: ' + e.toString());
      };
      // Create a new Blob and write it to log.txt.
      var bb = new BlobBuilder();
      bb.append('Meow');
      fileWriter.write(bb.getBlob('text/plain'));
    }, errorHandler);
  }, errorHandler);
}
window.requestFileSystem(window.TEMPORARY, 1024*1024, onInitFs, errorHandler);
					

规范

规范 状态 注释
文件和目录条目 API
在该规范中的 FileSystemFileEntry 定义。
草案 提议 API 草案

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
FileSystemFileEntry Chrome 8 Alternate Name
8 Alternate Name
Alternate Name Uses the non-standard name: FileEntry
Edge 79 Prefixed
79 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox 50 IE No Opera No Safari 11.1 WebView Android ≤37 Alternate Name
≤37 Alternate Name
Alternate Name Uses the non-standard name: FileEntry
Chrome Android 18 Alternate Name
18 Alternate Name
Alternate Name Uses the non-standard name: FileEntry
Firefox Android 50 Opera Android No Safari iOS 11.3 Samsung Internet Android Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: webkit
createWriter 弃用 非标 Chrome 8 Edge 79 Firefox 50 — 52
不支持 50 — 52
While the createWriter() method existed, it immediately called errorCallback 采用 NS_ERROR_DOM_SECURITY_ERR 错误。
IE No Opera No Safari No WebView Android ≤37 Chrome Android 18 Firefox Android 50 — 52
不支持 50 — 52
While the createWriter() method existed, it immediately called errorCallback 采用 NS_ERROR_DOM_SECURITY_ERR 错误。
Opera Android No Safari iOS No Samsung Internet Android Yes
file Chrome 8 Edge 79 Firefox 50 IE No Opera No Safari 11.1 WebView Android ≤37 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 11.3 Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

使用非标名称。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: