CSharp examples for Network:Web
Download a File and Process It Using a Stream
using System;//from w w w. ja v a 2 s .c om using System.Net; using System.IO; class MainClass{ public static void Main(string[] args) { string picUri = "http://book2s.com/resources/a.png"; string htmlUri = "http://www.book2s.com"; WebRequest requestPic = WebRequest.Create(picUri); WebRequest requestHtml = WebRequest.Create(htmlUri); WebResponse responsePic = requestPic.GetResponse(); WebResponse responseHtml = requestHtml.GetResponse(); //pictureBox1.Image = Image.FromStream(responsePic.GetResponseStream()); using (StreamReader r = new StreamReader(responseHtml.GetResponseStream())) { Console.WriteLine(r.ReadToEnd()); } } }