C# WebClient DownloadData(Uri)

Description

WebClient DownloadData(Uri) Downloads the resource as a Byte array from the URI specified.

Syntax

WebClient.DownloadData(Uri) has the following syntax.


public byte[] DownloadData(
  Uri address
)

Parameters

WebClient.DownloadData(Uri) has the following parameters.

  • address - The URI represented by the Uri object, from which to download data.

Returns

WebClient.DownloadData(Uri) method returns

Example


using System;//from  w  w w .  j  a va 2 s . com
using System.Net;
using System.Net.Sockets;
using System.Text;

public class Example
{
    public static void Main()
    {
        WebClient myWebClient = new WebClient();
        byte[] myDataBuffer = myWebClient.DownloadData(new Uri("http://www.java2s.com"));
        string download = Encoding.ASCII.GetString(myDataBuffer);
        Console.WriteLine(download);


    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient