FileReader Class
Reads the content of a Blob asynchronously (https://w3c.github.io/FileAPI/#APIASynch). The events (loadstart, progress, load or error, loadend, abort) are fired by the tasks of the event loop of the relevant global object of the reader (the window of the current global object when it is created); a reader created without current global object (e.g. from .NET without script engine) reads the blob and fires the events synchronously.
public sealed class FileReader : EventTarget- Inheritance
EventTargetFileReader
Constructors
| Name | Description |
|---|---|
| FileReader() | Creates a reader in the FileReader.Empty state. |
FileReader()
FileReader.csCreates a reader in the FileReader.Empty state.
public FileReader()Properties
| Name | Description |
|---|---|
| Error | Gets the error of the read, or null. |
| OnAbort | Gets or sets the event handler of the abort event. |
| OnError | Gets or sets the event handler of the error event. |
| OnLoad | Gets or sets the event handler of the load event. |
| OnLoadEnd | Gets or sets the event handler of the loadend event. |
| OnLoadStart | Gets or sets the event handler of the loadstart event. |
| OnProgress | Gets or sets the event handler of the progress event. |
| ReadyState | Gets the state of the reader: FileReader.Empty, FileReader.Loading or FileReader.Done. |
| Result | Gets the result of the read: a String, a Byte array (an ArrayBuffer in JavaScript), or null. |
Error
FileReader.csGets the error of the read, or null.
public DomException? Error { get; }OnAbort
FileReader.csGets or sets the event handler of the abort event.
OnError
FileReader.csGets or sets the event handler of the error event.
OnLoad
FileReader.csGets or sets the event handler of the load event.
OnLoadEnd
FileReader.csGets or sets the event handler of the loadend event.
OnLoadStart
FileReader.csGets or sets the event handler of the loadstart event.
OnProgress
FileReader.csGets or sets the event handler of the progress event.
ReadyState
FileReader.csGets the state of the reader: FileReader.Empty, FileReader.Loading or FileReader.Done.
public ushort ReadyState { get; }Result
FileReader.cspublic FileReaderResult? Result { get; }Methods
| Name | Description |
|---|---|
| Abort() | Aborts the read (https://w3c.github.io/FileAPI/#dfn-abort). |
| ReadAsArrayBuffer(Blob) | Reads the blob as bytes (https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer). |
| ReadAsBinaryString(Blob) | Reads the blob as a binary string: each byte is a code unit (https://w3c.github.io/FileAPI/#readAsBinaryString). |
| ReadAsDataUrl(Blob) | Reads the blob as a data: URL whose body is base64-encoded (https://w3c.github.io/FileAPI/#dfn-readAsDataURL). |
| ReadAsText(Blob, string?) | Reads the blob as text (https://w3c.github.io/FileAPI/#readAsDataText), decoded with the byte order mark, else the encoding label, else the charset of the type of the blob, else UTF-8. |
Abort()
FileReader.csAborts the read (https://w3c.github.io/FileAPI/#dfn-abort).
public void Abort()ReadAsArrayBuffer(Blob)
FileReader.csReads the blob as bytes (https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer).
ReadAsBinaryString(Blob)
FileReader.csReads the blob as a binary string: each byte is a code unit (https://w3c.github.io/FileAPI/#readAsBinaryString).
ReadAsDataUrl(Blob)
FileReader.csReads the blob as a data: URL whose body is base64-encoded (https://w3c.github.io/FileAPI/#dfn-readAsDataURL).
ReadAsText(Blob, string?)
FileReader.csReads the blob as text (https://w3c.github.io/FileAPI/#readAsDataText), decoded with the byte order mark, else the encoding label, else the charset of the type of the blob, else UTF-8.
Constants
| Name | Description |
|---|---|
| Done | The state of a reader whose read has completed (DONE). |
| Empty | The state of a reader that has no read in progress and no result (EMPTY). |
| Loading | The state of a reader that is reading a blob (LOADING). |
Done
The state of a reader whose read has completed (DONE).
public const ushort Done = 2Empty
The state of a reader that has no read in progress and no result (EMPTY).
public const ushort Empty = 0Loading
The state of a reader that is reading a blob (LOADING).
public const ushort Loading = 1