Returns the data stream from the Internet resource.
using System;
using System.Text;
using System.Net;
using System.IO;
class MainClass
{
public static void Main()
{
WebRequest myWebRequest = WebRequest.Create("http://www.google.com");
WebResponse myWebResponse = myWebRequest.GetResponse();
Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(ReceiveStream, encode);
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
while (count > 0)
{
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
readStream.Close();
myWebResponse.Close();
}
}
Related examples in the same category