Mega Code Archive

 
Categories / C# Tutorial / Network
 

Use WebRequest

using System; using System.Net; using System.IO; class MainClass {   [STAThread]   static void Main(string[] args)   {     WebRequest MyRequest = WebRequest.Create("http://www.rntsoft.com");     WebResponse MyResponse = MyRequest.GetResponse();     Stream MyStream = MyResponse.GetResponseStream();     StreamReader MyReader = new StreamReader(MyStream);     string MyWebLine;     while ((MyWebLine = MyReader.ReadLine()) != null)     {       Console.WriteLine(MyWebLine);     }     MyStream.Close();   } }