Table of Contents

Class CoreWebView2DownloadOperation

Namespace
Microsoft.Web.WebView2.Core
Assembly
Microsoft.Web.WebView2.Core.dll

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

public class CoreWebView2DownloadOperation
Inheritance
CoreWebView2DownloadOperation
Inherited Members

Properties

BytesReceived

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

public long BytesReceived { get; }

Property Value

long

Examples

CanResume

Returns true if an interrupted download can be resumed.

public bool CanResume { get; }

Property Value

bool

Remarks

Downloads with the following interrupt reasons may automatically resume without you calling any methods: ServerNoRange, FileHashMismatch, FileTooShort. In these cases progress may be restarted with BytesReceived set to 0.

ContentDisposition

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

public string ContentDisposition { get; }

Property Value

string

EstimatedEndTime

The estimated end time of the download.

public DateTime EstimatedEndTime { get; }

Property Value

DateTime

InterruptReason

The reason why connection with file host was broken.

public CoreWebView2DownloadInterruptReason InterruptReason { get; }

Property Value

CoreWebView2DownloadInterruptReason

Remarks

See CoreWebView2DownloadInterruptReason for descriptions of reasons.

MimeType

MIME type of the downloaded content.

public string MimeType { get; }

Property Value

string

ResultFilePath

The absolute path to the download file, including file name.

public string ResultFilePath { get; }

Property Value

string

Remarks

Host can change this from ResultFilePath.

State

The state of the download. A download can be in progress, interrupted, or completed.

public CoreWebView2DownloadState State { get; }

Property Value

CoreWebView2DownloadState

Remarks

See CoreWebView2DownloadState for descriptions of states.

TotalBytesToReceive

The total bytes to receive count.

public ulong? TotalBytesToReceive { get; }

Property Value

ulong?

Uri

The URI of the download.

public string Uri { get; }

Property Value

string

Methods

Cancel()

Cancels the download.

public void Cancel()

Remarks

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

Pause()

Pauses the download.

public void Pause()

Remarks

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 UserCanceled.

Resume()

Resumes a paused download. May also resume a download that was interrupted for another reason if CanResume returns true.

public void Resume()

Remarks

Resuming a download changes the state from interrupted to in progress.

Events

BytesReceivedChanged

Event raised when the bytes received count is updated.

public event EventHandler<object> BytesReceivedChanged

Event Type

EventHandler<object>

EstimatedEndTimeChanged

Event raised when the estimated end time changes.

public event EventHandler<object> EstimatedEndTimeChanged

Event Type

EventHandler<object>

StateChanged

Event raised when the state of the download changes.

public event EventHandler<object> StateChanged

Event Type

EventHandler<object>

Examples

Remarks

Use State to get the current state, and InterruptReason to get the reason if the download is interrupted.