using System;
using System.Net;
using System.IO;
using System.Text;

class WebClientTest
{
    static void Main(String[] args)
    {
        string url = "http://www.google.com.tw";
        String localfile = "google.htm";

        WebProxy proxy = new WebProxy("http://proxy.internal:3128/", true);
        // 建立WebClient物件
        WebClient webclient = new WebClient();
        webclient.Proxy = proxy;

        // 下載檔案
        try
        {
            // 自指定URI下載資料，並儲存為本機之檔案
            webclient.DownloadFile(url, localfile);

            Console.WriteLine("Download file completed.");
        }
        catch (WebException ex)
        {
            Console.WriteLine(ex.StackTrace.ToString());
        }

        webclient.Dispose();
    }
}

