C# WebClient OpenRead(Uri)

Description

WebClient OpenRead(Uri) Opens a readable stream for the data downloaded from a resource with the URI specified as a Uri

Syntax

WebClient.OpenRead(Uri) has the following syntax.


public Stream OpenRead(
  Uri address
)

Parameters

WebClient.OpenRead(Uri) has the following parameters.

  • address - The URI specified as a Uri from which to download data.

Returns

WebClient.OpenRead(Uri) method returns A Stream used to read data from a resource.

Example


using System;/*from w w  w  . ja  v  a  2 s . com*/
using System.Net;
using System.Net.Sockets;
using System.IO;

public class Example
{
    public static void Main()
    {
        WebClient myWebClient = new WebClient();
        Stream myStream = myWebClient.OpenRead(new Uri("http://java2s.com"));

        StreamReader sr = new StreamReader(myStream);
        Console.WriteLine(sr.ReadToEnd());
        myStream.Close();

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient