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

Applies to Windows and Windows Phone

Initializes a DownloadOperation object that contains the specified Uri and the file that the response is written to.

Syntax

Public Function CreateDownload(
  uri As Uri,  
  resultFile As IStorageFile 
) As DownloadOperation

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.

Return value

Type: DownloadOperation

The resultant download operation.

Remarks

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, IStorageFile)

 

 

Show:
© 2014 Microsoft. All rights reserved.