Tuesday, July 11, 2006

A Downloader

I was enthralled by the peugeot parking game . I wanted to have this game on my local machine so I could play this whenever I wanted to. I also have the faced the same problem when I'm browsing PDF documents on the Net that disallows saving. I wrote this simple C# program that did it for me. Thanks to .Net SDK 2.0, it's just a couple of lines of code: using System; using System.Net; using System.IO; public class Downloader { public static void Main(string [] args) { if(args.Length == 0 || args.Length > 2) { Console.WriteLine("Usage: Downloader <Url to download> <new filename>"); return; } WebClient client = new WebClient(); string filename = @".\" + Path.GetFileName(args[0]) ; if(args.Length ==2) filename = args[1]; client.DownloadFile(args[0], filename); } } Now, I can play the game whenever I want :)

No comments: