DownloadedFile Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A buffered, point-in-time snapshot of a downloaded file's bytes that the caller owns.
Returned by DownloadAsync(CancellationToken). The bytes are already in memory, so the convenience readers here are synchronous and never re-download. Because it is a snapshot, holding one and reusing it is the way to read the same file several ways without re-fetching through the live IncomingFile handle.
public sealed class DownloadedFile
type DownloadedFile = class
Public NotInheritable Class DownloadedFile
- Inheritance
-
DownloadedFile
Properties
| Name | Description |
|---|---|
| Bytes |
The file bytes, buffered from the download stream read to completion. |
| ContentType |
MIME type resolved from the download response header, or the incoming file's metadata type if the response omits one. Falls back to |
| Filename |
Resolved filename. |
| SourceUrl |
The URL the bytes were actually fetched from. |
Methods
| Name | Description |
|---|---|
| SaveAsAsync(String, CancellationToken) |
Write the already-buffered bytes to a local file path (no re-fetch, unlike SaveAsAsync(String, CancellationToken) which streams a fresh download). |
| Text(Encoding) |
Decode bytes as UTF-8 (or a provided encoding). No content-type check. Lossy: invalid bytes become the U+FFFD replacement character and never throw. For strict or binary-safe reads, use Bytes. |