Access an FTP Site

Problem

You want to retrieve or upload files from an FTP server.

Solution

Use a third-party component, or create a dedicated class that sends FTP commands over a TCP connection.

Discussion

FTP (File Transfer Protocol) is a common protocol used to upload and download files from a server. FTP, like many Internet protocols, defines a small set of commands that are sent as simple ASCII-encoded messages over a TCP connection (typically on port 21).

The following is a listing of a typical FTP dialogue, starting immediately after the client makes a TCP connection. Notice that every line sent from the server begins with an FTP response code.

Server sends: 220-FTP server ready. Server sends: 220-<< Server sends: 220- Server sends: 220->> Server ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook 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.