Namespace: SpawnDev.SpawnJS.JSObjects
Source: JSObjects/FileSystemWriteOptions.cs
MDN Reference: FileSystemWriteOptions on MDN
Options used when calling FileSystemWritableFileStream.Write() https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write#data
| Property | Type | Access | Description |
|---|---|---|---|
FileSystemWriteOptions |
class |
get | Options used when calling FileSystemWritableFileStream.Write() https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream/write#data |
Data |
Union<ArrayBuffer, TypedArray, DataView, Blob, string, byte[]>? |
get/set | |
Position |
ulong? |
get/set | |
Size |
ulong? |
get |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<FileSystemWriteOptions>(...)or constructornew FileSystemWriteOptions(...)
async function saveFile() {
try {
// create a new handle
const newHandle = await window.showSaveFilePicker();
// create a FileSystemWritableFileStream to write to
const writableStream = await newHandle.createWritable();
// write our file
await writableStream.write("This is my file content");
// close the file and write the contents to disk.
await writableStream.close();
} catch (err) {
console.error(err.name, err.message);
}
}// just pass in the data (no options)
writableStream.write(data);
// writes the data to the stream from the determined position
writableStream.write({ type: "write", position, data });
// updates the current file cursor offset to the position specified
writableStream.write({ type: "seek", position });
// resizes the file to be size bytes long
writableStream.write({ type: "truncate", size });