Table of Contents

Class FileSystemWritableFileStream

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The FileSystemWritableFileStream interface of the {{domxref("File System API", "File System API", "", "nocode")}} is a 'WritableStream' object with additional convenience methods, which operates on a single file on disk. The interface is accessed through the 'FileSystemFileHandle.CreateWritable' method.

[Value("FileSystemWritableFileStream")]
public class FileSystemWritableFileStream : WritableStream
Inheritance
FileSystemWritableFileStream
Inherited Members

Remarks

Constructors

FileSystemWritableFileStream()

public FileSystemWritableFileStream()

Methods

Seek(ulong)

The seek() method of the FileSystemWritableFileStream interface updates the current file cursor offset to the position (in bytes) specified when calling the method.

[Value("seek")]
public Task<GlobalObject.Undefined> Seek(ulong position)

Parameters

position ulong

Returns

Task<GlobalObject.Undefined>

A 'Promise' that returns undefined.

Remarks

Truncate(ulong)

The truncate() method of the FileSystemWritableFileStream interface resizes the file associated with the stream to the specified size in bytes.

[Value("truncate")]
public Task<GlobalObject.Undefined> Truncate(ulong size)

Parameters

size ulong

Returns

Task<GlobalObject.Undefined>

A 'Promise' that returns undefined.

Remarks

If the size specified is larger than the current file size the file is padded with 0x00 bytes.

The file cursor is also updated when truncate() is called.
If the offset is smaller than the size, it remains unchanged.
If the offset is larger than size, the offset is set to that size.
This ensures that subsequent writes do not error.

No changes are written to the actual file on disk until the stream has been closed.
Changes are typically written to a temporary file instead.

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

See also on MDN

Write(Union48)

The write() method of the FileSystemWritableFileStream interface writes content into the file the method is called on, at the current file cursor offset.

[Value("write")]
public Task<GlobalObject.Undefined> Write(Union48 data)

Parameters

data Union48

Returns

Task<GlobalObject.Undefined>

A 'Promise' that returns undefined.

Remarks

No changes are written to the actual file on disk until the stream has been closed.
Changes are typically written to a temporary file instead. This method can also be used to seek to a byte point within the stream and truncate to modify the total bytes the file contains.

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

See also on MDN