C# WebClient DownloadData(String)

Description

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

Syntax

WebClient.DownloadData(String) has the following syntax.


public byte[] DownloadData(
  string address
)

Parameters

WebClient.DownloadData(String) has the following parameters.

  • address - The URI from which to download data.

Returns

WebClient.DownloadData(String) method returns

Example


using System;/* ww  w  .ja va  2 s .c o m*/
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("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