WebClient.DownloadString Metodo
Definizione
Overload
DownloadString(String) |
Scarica la risorsa richiesta come oggetto String.Downloads the requested resource as a String. La risorsa da scaricare viene specificata come String contenente l'URI.The resource to download is specified as a String containing the URI. |
DownloadString(Uri) |
Scarica la risorsa richiesta come oggetto String.Downloads the requested resource as a String. La risorsa da scaricare viene specificata come classe Uri.The resource to download is specified as a Uri. |
DownloadString(String)
public:
System::String ^ DownloadString(System::String ^ address);
public string DownloadString (string address);
member this.DownloadString : string -> string
Public Function DownloadString (address As String) As String
Parametri
Restituisce
String contenente la risorsa richiesta.A String containing the requested resource.
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.
Questo metodo è stato chiamato simultaneamente su più thread.The method has been called simultaneously on multiple threads.
Esempio
Nell'esempio di codice riportato di seguito viene illustrata la chiamata a questo metodo.The following code example demonstrates calling this method.
void DownloadString( String^ address )
{
WebClient^ client = gcnew WebClient;
String^ reply = client->DownloadString( address );
Console::WriteLine( reply );
}
public static void DownloadString(string address)
{
WebClient client = new WebClient();
string reply = client.DownloadString(address);
Console.WriteLine(reply);
}
Public Shared Sub DownloadString(ByVal address As String)
Dim client As WebClient = New WebClient()
Dim reply As String = client.DownloadString(address)
Console.WriteLine(reply)
End Sub
Commenti
Questo metodo recupera la risorsa specificata.This method retrieves the specified resource. Dopo aver scaricato la risorsa, il metodo usa la codifica specificata nella Encoding proprietà per convertire la risorsa in String .After it downloads the resource, the method uses the encoding specified in the Encoding property to convert the resource to a String. Questo metodo si blocca durante il download della risorsa.This method blocks while downloading the resource. Per scaricare una risorsa e continuare l'esecuzione durante l'attesa della risposta del server, usare uno dei DownloadStringAsync metodi.To download a resource and continue executing while waiting for the server's response, use one of the DownloadStringAsync methods.
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.
Si applica a
DownloadString(Uri)
public:
System::String ^ DownloadString(Uri ^ address);
public string DownloadString (Uri address);
member this.DownloadString : Uri -> string
Public Function DownloadString (address As Uri) As String
Parametri
Restituisce
String contenente la risorsa richiesta.A String containing the requested resource.
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.
Questo metodo è stato chiamato simultaneamente su più thread.The method has been called simultaneously on multiple threads.
Commenti
Questo metodo recupera la risorsa specificata.This method retrieves the specified resource. Dopo aver scaricato la risorsa, il metodo usa la codifica specificata nella Encoding proprietà per convertire la risorsa in String .After it downloads the resource, the method uses the encoding specified in the Encoding property to convert the resource to a String. Questo metodo si blocca durante il download della risorsa.This method blocks while downloading the resource. Per scaricare una risorsa e continuare l'esecuzione durante l'attesa della risposta del server, usare uno dei DownloadStringAsync metodi.To download a resource and continue executing while waiting for the server's response, use one of the DownloadStringAsync methods.
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.