FTPTREE: Displays the Structure and Content of an FTP Site

Click to open or copy the FTPTREE project files.

The FTPTREE sample application illustrates the following MFC Internet client (WinInet) features:

FTPTREE is a simple dialog application that has one edit box (for the name of the server and optionally a path to an object on that server) and a standard tree control object. The tree control belongs to the dialog box, and displays either an error message or the contents (up to 128 items) of an FTP site specified in the ftp:// edit box.

The CInternetSession object encapsulates the connection to the Internet (or intranet). This object persists while the FTPTREE dialog exists in memory, though it could just as easily be opened only when needed (and closed immediately after) with little overhead.

If an Internet session object cannot be initialized based on the configuration specified in the registry entry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings, an error is displayed and the application shuts down.

Running the Sample

FTPTREE opens an Internet session based on the configuration specified in the registry. Valid inputs for the ftp:// edit box are the following.

You can add the protocol prefix ftp:// to any of the above entries.

TIS Proxy May Be Needed for Connection

The FTPTREE sample, and Wininet.dll in general, require either a direct connection to an FTP server or a connection to an FTP server via a TIS proxy. FTPTREE, CFtpConnection, and direct WININET API calls will not work correctly with CERN FTP proxies.

The FTPTREE sample uses proxy information specified in the registry. If you get messages such as "The connection with the server was reset" indicating FTPTREE is unable to connect with an Internet site, your may need to change your preconfigured registry settings to specify a TIS proxy for FTP services. These settings are easily changed from Internet Explorer on the Connection tab of the Options property sheet. The corresponding registry entries are:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"
"ProxyServer"
"ProxyOverride"

This sample demonstrates the following keywords:

CFtpConnection::CFtpConnection; CFtpConnection::SetCurrentDirectory; CFtpConnection::GetCurrentDirectory; CFtpConnection::Close; CFtpFileFind::CFtpFileFind; CFtpFileFind::FindFile, CFtpFileFind::FindNextFile; CFileFind::IsDirectory; CInternetSession::CInternetSession;  CInternetSession::GetFtpConnection; CInternetSession::Close;