using System; using System.Drawing; using System.Windows.Forms; using System.IO; using System.Net; public class FetchImageWeb : Form { /// /// The Web Request program Bishop and Horspool March 2003 /// ======================= /// /// Access the web to fetch and display an image /// Illustrates web requests with http or file protocols. /// Your command line request should contain an address of the form /// http://www.google.com/images/logo.gif or /// file://c:/My Work/images/Jacarandas.jpg /// Image pic; protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawImage(pic,30,30); } public FetchImageWeb(String url){ this.Size = new Size(400,400); this.Text = "Web request"; WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); pic = Image.FromStream(stream); } static void Main(string[] args) { Application.Run(new FetchImageWeb(args[0])); } }