// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Net; using System.Web; class MainClass { public static void Main(string[] args) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.eksperten.dk/img/elogo.png"); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); string filename = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) + "\\elogo.png"; Stream f1 = resp.GetResponseStream(); Stream f2 = new FileStream(filename, FileMode.CreateNew, FileAccess.Write); byte[] b = new byte[1000]; int n; while((n = f1.Read(b, 0, b.Length)) > 0) { f2.Write(b, 0, n); } f2.Close(); f1.Close(); resp.Close(); } }