Open a readable stream for the data downloaded from a resource with the URI specified as a String in CSharp
Description
The following code shows how to open a readable stream for the data downloaded from a resource with the URI specified as a String.
Example
using System;//from w w w .j a v a 2 s . c o m
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("http://java2s.com");
StreamReader sr = new StreamReader(myStream);
Console.WriteLine(sr.ReadToEnd());
myStream.Close();
}
}
The code above generates the following result.