Download file from Web

If you want to download file from the internet using Phalanger, you can use .NET class WebClient that makes this task as easy as possible. The class has method called DownloadFile that downloads file (web address) to specified location in your file system. This is demonstrated by the following example:
import namespace System;
import namespace System:::Net;

// function for downloading files from the internet
function download($path, $name)
  $client = new WebClient;
  $client->DownloadFile(new Uri($path), $name);

download("", "C:\\test.html");  

If you need more control, for example you want to download file only in the memory, you can use HttpWebRequest class.

Last edited Oct 22, 2006 at 1:35 AM by tomasp, version 1


No comments yet.