Compartilhar via


CoreWebView2DownloadOperation Class

Represents a download operation. Gives access to a download's metadata and supports a user canceling, pausing, or resuming a download.

Summary

Members Description
BytesReceived The number of bytes that have been written to the download file.
CanResume Returns true if an interrupted download can be resumed.
ContentDisposition The Content-Disposition header value from the download's HTTP response. If none, the value is an empty string.
EstimatedEndTime The estimated end time of the download.
InterruptReason The reason why connection with file host was broken.
MimeType MIME type of the downloaded content.
ResultFilePath The absolute path to the download file, including file name.
State The state of the download. A download can be in progress, interrupted, or completed.
TotalBytesToReceive The expected size of the download in total number of bytes based on the HTTP Content-Length header.
Uri The URI of the download.
Cancel Cancels the download.
Pause Pauses the download.
Resume Resumes a paused download. May also resume a download that was interrupted for another reason if CoreWebView2DownloadOperation.CanResume returns true.
BytesReceivedChanged Event raised when the bytes received count is updated.
EstimatedEndTimeChanged Event raised when the estimated end time changes.
StateChanged Event raised when the state of the download changes.

Properties

BytesReceived

readonly int64_t BytesReceived

The number of bytes that have been written to the download file.

CanResume

readonly bool CanResume

Returns true if an interrupted download can be resumed. Downloads with the following interrupt reasons may automatically resume without you calling any methods: CoreWebView2DownloadInterruptReason.ServerNoRange, CoreWebView2DownloadInterruptReason.FileHashMismatch, CoreWebView2DownloadInterruptReason.FileTooShort. In these cases progress may be restarted with CoreWebView2DownloadOperation.BytesReceived set to 0.

ContentDisposition

readonly string ContentDisposition

The Content-Disposition header value from the download's HTTP response. If none, the value is an empty string.

EstimatedEndTime

readonly string EstimatedEndTime

The estimated end time of the download.

InterruptReason

readonly CoreWebView2DownloadInterruptReason InterruptReason

The reason why connection with file host was broken. See CoreWebView2DownloadInterruptReason for descriptions of reasons.

MimeType

readonly string MimeType

MIME type of the downloaded content.

ResultFilePath

readonly string ResultFilePath

The absolute path to the download file, including file name. Host can change this from CoreWebView2DownloadStartingEventArgs.ResultFilePath.

State

readonly CoreWebView2DownloadState State

The state of the download. A download can be in progress, interrupted, or completed. See CoreWebView2DownloadState for descriptions of states.

TotalBytesToReceive

readonly int64_t TotalBytesToReceive

The expected size of the download in total number of bytes based on the HTTP Content-Length header. Returns null if the size is unknown.

Uri

readonly string Uri

The URI of the download.

Methods

Cancel

void Cancel()

Cancels the download. If canceled, the default download dialog shows that the download was canceled. Host should use CoreWebView2DownloadStartingEventArgs.Cancel if download should be canceled without displaying the default download dialog.

Pause

void Pause()

Pauses the download. If paused, the default download dialog shows that the download is paused. No effect if download is already paused. Pausing a download changes the state from in progress to interrupted, with interrupt reason set to CoreWebView2DownloadInterruptReason.UserCanceled.

Resume

void Resume()

Resumes a paused download. May also resume a download that was interrupted for another reason if CoreWebView2DownloadOperation.CanResume returns true. Resuming a download changes the state from interrupted to in progress.

Events

BytesReceivedChanged

Event raised when the bytes received count is updated.

Type: TypedEventHandler<CoreWebView2DownloadOperation, Object>

EstimatedEndTimeChanged

Event raised when the estimated end time changes.

Type: TypedEventHandler<CoreWebView2DownloadOperation, Object>

StateChanged

Event raised when the state of the download changes. Use CoreWebView2DownloadOperation.State to get the current state, and CoreWebView2DownloadOperation.InterruptReason to get the reason if the download is interrupted.

Type: TypedEventHandler<CoreWebView2DownloadOperation, Object>

Referenced by