11.3. Download Data over HTTP or FTP

Problem

You need a quick, simple way to download data from the Internet using HTTP or FTP.

Solution

Use the methods of the System.Net.WebClient class or the DownloadFile method of the My.Computer.Network class. (Refer to Chapter 5 for more information about the My object.)

How It Works

The .NET Framework provides several mechanisms for transferring data over the Internet. One of the easiest approaches is to use the System.Net.WebClient class. WebClient provides many high-level methods that simplify the transfer of data by specifying the source as a uniform resource identifier (URI); Table 11-2 summarizes them. The URI can specify that a file (file://), FTP (ftp://), HTTP ((http://), or HTTPS (https://) protocol ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.