Table of Contents

Class FileSystemFileHandle

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The FileSystemFileHandle interface of the {{domxref("File System API", "File System API", "", "nocode")}} represents a handle to a file system entry. The interface is accessed through the 'window.ShowOpenFilePicker' method.

[Value("FileSystemFileHandle")]
public class FileSystemFileHandle : FileSystemHandle
Inheritance
FileSystemFileHandle
Inherited Members

Remarks

Note that read and write operations depend on file-access permissions that do not persist after a page refresh if no other tabs for that origin remain open. The QueryPermission(FileSystemHandlePermissionDescriptor) method of the FileSystemHandle interface can be used to verify permission state before accessing a file.

-File System API
-The File System Access API: simplifying access to local files

See also on MDN

Constructors

FileSystemFileHandle()

public FileSystemFileHandle()

Methods

CreateSyncAccessHandle()

The createSyncAccessHandle() method of the
FileSystemFileHandle interface returns a {{jsxref('Promise')}} which resolves to a 'FileSystemSyncAccessHandle' object
that can be used to synchronously read from and write to a file. The synchronous nature of this method brings performance advantages,
but it is only usable inside dedicated Web Workers for files within the origin private file system.

[Value("createSyncAccessHandle")]
public Task<FileSystemSyncAccessHandle> CreateSyncAccessHandle()

Returns

Task<FileSystemSyncAccessHandle>

A {{jsxref('Promise')}} which resolves to a 'FileSystemSyncAccessHandle' object.

Remarks

Creating a 'FileSystemSyncAccessHandle' takes an exclusive lock on the file associated with the file handle. This prevents the creation of further 'FileSystemSyncAccessHandle's or 'FileSystemWritableFileStream's for the file until the existing access handle is closed.

-File System API
-The File System Access API: simplifying access to local files

See also on MDN

CreateWritable(FileSystemCreateWritableOptions)

The createWritable() method of the FileSystemFileHandle interface creates a 'FileSystemWritableFileStream' that can be used to write to a file.
The method returns a 'Promise' which resolves to this created stream.

[Value("createWritable")]
public Task<FileSystemWritableFileStream> CreateWritable(FileSystemCreateWritableOptions options = null)

Parameters

options FileSystemCreateWritableOptions

Returns

Task<FileSystemWritableFileStream>

A {{jsxref('Promise')}} which resolves to a 'FileSystemWritableFileStream' object.

Remarks

Any changes made through the stream won&apos;t be reflected in the file represented by the file handle until the stream has been closed.
This is typically implemented by writing data to a temporary file, and only replacing the file represented by file handle with the temporary file when the writable file stream is closed.

-File System API
-The File System Access API: simplifying access to local files

See also on MDN

GetFile()

The getFile() method of the
FileSystemFileHandle interface returns a {{jsxref('Promise')}} which resolves to a
'File' object representing the state on disk of the entry represented by the handle.

[Value("getFile")]
public Task<File> GetFile()

Returns

Task<File>

A {{jsxref('Promise')}} which resolves to a 'File' object.

Remarks

If the file on disk changes or is removed after this method is called, the returned
'File' object will likely be no longer readable.

-File System API
-The File System Access API: simplifying access to local files

See also on MDN