WebClient.DownloadDataTaskAsync Metodo
Definizione
Scarica la risorsa come matrice Byte dall'URI specificato come operazione asincrona utilizzando un oggetto attività.Downloads the resource as a Byte array from the URI specified as an asynchronous operation using a task object. Questi metodi non bloccano il thread chiamante.These methods do not block the calling thread.
Overload
DownloadDataTaskAsync(String) |
Scarica la risorsa come matrice Byte dall'URI specificato come operazione asincrona utilizzando un oggetto attività.Downloads the resource as a Byte array from the URI specified as an asynchronous operation using a task object. |
DownloadDataTaskAsync(Uri) |
Scarica la risorsa come matrice Byte dall'URI specificato come operazione asincrona utilizzando un oggetto attività.Downloads the resource as a Byte array from the URI specified as an asynchronous operation using a task object. |
DownloadDataTaskAsync(String)
public:
System::Threading::Tasks::Task<cli::array <System::Byte> ^> ^ DownloadDataTaskAsync(System::String ^ address);
public System.Threading.Tasks.Task<byte[]> DownloadDataTaskAsync (string address);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<byte[]> DownloadDataTaskAsync (string address);
member this.DownloadDataTaskAsync : string -> System.Threading.Tasks.Task<byte[]>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.DownloadDataTaskAsync : string -> System.Threading.Tasks.Task<byte[]>
Public Function DownloadDataTaskAsync (address As String) As Task(Of Byte())
Parametri
- address
- String
L'URI della risorsa di cui eseguire il download.The URI of the resource to download.
Restituisce
Oggetto dell'attività che rappresenta l'operazione asincrona.The task object representing the asynchronous operation. La proprietà Result nell'oggetto attività restituisce una matrice Byte che contiene la risorsa scaricata.The Result property on the task object returns a Byte array containing the downloaded resource.
- Attributi
Eccezioni
Il valore del parametro address
è null
.The address
parameter is null
.
L'URI ottenuto combinando BaseAddress e address
non è valido.The URI formed by combining BaseAddress and address
is invalid.
-oppure--or-
Si è verificato un errore durante il download della risorsa.An error occurred while downloading the resource.
Commenti
Questa operazione non verrà bloccata.This operation will not block. L' Task<TResult> oggetto restituito viene completato dopo il download della risorsa dati.The returned Task<TResult> object will complete after the data resource has been downloaded.
Questo metodo recupera la risorsa specificata utilizzando il metodo predefinito per il protocollo associato allo schema URI specificato nel address
parametro.This method retrieves the specified resource using the default method for the protocol associated with the URI scheme specified in the address
parameter. I dati vengono scaricati in modo asincrono usando le risorse del thread allocate automaticamente dal pool di thread.The data is downloaded asynchronously using thread resources that are automatically allocated from the thread pool.
Se la BaseAddress proprietà non è una stringa vuota ("") e non address
contiene un URI assoluto, address
deve essere un URI relativo combinato con BaseAddress per formare l'URI assoluto dei dati richiesti.If the BaseAddress property is not an empty string ("") and address
does not contain an absolute URI, address
must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. Se la QueryString proprietà non è una stringa vuota, viene aggiunta a address
.If the QueryString property is not an empty string, it is appended to address
.
Questo metodo usa il comando RETR per scaricare una risorsa FTP.This method uses the RETR command to download an FTP resource. Per una risorsa HTTP, viene usato il metodo GET.For an HTTP resource, the GET method is used.
Nota
Questo membro genera informazioni di traccia quando viene abilitata la funzionalità di traccia di rete nell'applicazione in uso.This member outputs trace information when you enable network tracing in your application. Per ulteriori informazioni, vedere la pagina relativa alla traccia di rete in .NET Framework.For more information, see Network Tracing in .NET Framework.
Nell'esempio di codice seguente vengono richiesti dati da un server e vengono visualizzati i dati restituiti.The following code example requests data from a server and displays the data returned. Si presuppone che remoteUri
contenga un URI valido per i dati richiesti.It assumes that remoteUri
contains a valid URI for the requested data.
Si applica a
DownloadDataTaskAsync(Uri)
public:
System::Threading::Tasks::Task<cli::array <System::Byte> ^> ^ DownloadDataTaskAsync(Uri ^ address);
public System.Threading.Tasks.Task<byte[]> DownloadDataTaskAsync (Uri address);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task<byte[]> DownloadDataTaskAsync (Uri address);
member this.DownloadDataTaskAsync : Uri -> System.Threading.Tasks.Task<byte[]>
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.DownloadDataTaskAsync : Uri -> System.Threading.Tasks.Task<byte[]>
Public Function DownloadDataTaskAsync (address As Uri) As Task(Of Byte())
Parametri
- address
- Uri
L'URI della risorsa di cui eseguire il download.The URI of the resource to download.
Restituisce
Oggetto dell'attività che rappresenta l'operazione asincrona.The task object representing the asynchronous operation. La proprietà Result nell'oggetto attività restituisce una matrice Byte che contiene la risorsa scaricata.The Result property on the task object returns a Byte array containing the downloaded resource.
- Attributi
Eccezioni
Il valore del parametro address
è null
.The address
parameter is null
.
L'URI ottenuto combinando BaseAddress e address
non è valido.The URI formed by combining BaseAddress and address
is invalid.
-oppure--or-
Si è verificato un errore durante il download della risorsa.An error occurred while downloading the resource.
Commenti
Questa operazione non verrà bloccata.This operation will not block. L' Task<TResult> oggetto restituito viene completato dopo il download della risorsa dati.The returned Task<TResult> object will complete after the data resource has been downloaded.
Questo metodo recupera la risorsa specificata utilizzando il metodo predefinito per il protocollo associato allo schema URI specificato nel address
parametro.This method retrieves the specified resource using the default method for the protocol associated with the URI scheme specified in the address
parameter. I dati vengono scaricati in modo asincrono usando le risorse del thread allocate automaticamente dal pool di thread.The data is downloaded asynchronously using thread resources that are automatically allocated from the thread pool.
Se la BaseAddress proprietà non è una stringa vuota ("") e non address
contiene un URI assoluto, address
deve essere un URI relativo combinato con BaseAddress per formare l'URI assoluto dei dati richiesti.If the BaseAddress property is not an empty string ("") and address
does not contain an absolute URI, address
must be a relative URI that is combined with BaseAddress to form the absolute URI of the requested data. Se la QueryString proprietà non è una stringa vuota, viene aggiunta a address
.If the QueryString property is not an empty string, it is appended to address
.
Questo metodo usa il comando RETR per scaricare una risorsa FTP.This method uses the RETR command to download an FTP resource. Per una risorsa HTTP, viene usato il metodo GET.For an HTTP resource, the GET method is used.
Nota
Questo membro genera informazioni di traccia quando viene abilitata la funzionalità di traccia di rete nell'applicazione in uso.This member outputs trace information when you enable network tracing in your application. Per ulteriori informazioni, vedere la pagina relativa alla traccia di rete in .NET Framework.For more information, see Network Tracing in .NET Framework.