BackgroundDownloader.CreateDownload(Uri, IStorageFile, IStorageFile) | createDownload(Uri, IStorageFile, IStorageFile) method

Applies to Windows and Windows Phone

Initializes a DownloadOperation object with the resource Uri, the file that the response is written to, and the request entity body.

Syntax


var downloadOperation = backgroundDownloader.createDownload(uri, resultFile, requestBodyFile);

Parameters

uri

Type: Windows.Foundation.Uri [JavaScript] | System.Uri [.NET] | Windows::Foundation::Uri [C++]

The location of the resource.

resultFile

Type: IStorageFile

The file that the response will be written to.

requestBodyFile

Type: IStorageFile

A file that represents the request entity body, which contains additional data the server requires before the download can begin. The file this object points to must be valid for the duration of the download.

Return value

Type: DownloadOperation

The resultant download operation.

Remarks

The resultant DownloadOperation supports scenarios where a valid download request contains specific data required by the server. For example, a website requires a filled out form before the download can take place.

Background transfer doesn't support concurrent downloads of the same Uri. So an app can download http://example.com/myfile.wmv once, or download it again after a previous download completed. An app shouldn't start two downloads of the same Uri concurrently, since this may result in truncated files.

Important  

Creating a large number of transfers on the main UI thread with CreateDownload can result in degraded performance of your app's UI. If you are queuing up a large number of transfers, it is recommended that you call CreateDownload on a background worker thread as in the following example.


operation = await Task.Run(() => { return myDownloader.CreateDownload(uri, file); });


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Networking.BackgroundTransfer
Windows::Networking::BackgroundTransfer [C++]

Metadata

Windows.winmd

See also

BackgroundDownloader
CreateDownload(Uri, IStorageFile)

 

 

Show:
© 2014 Microsoft