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.
FTPTREE opens an Internet session based on the configuration specified in the registry. Valid inputs for the ftp://
edit box are the following.
myserver
— Only the name of the intranet FTP server.www.myserver.com
— Only the name of the Internet FTP server.myserver/dir/
— The name of an FTP server and a path. The path will be expanded in the tree control. myserver/dir/file
— The name of an FTP server and a path to a specific object. The object will be selected if found; if the object is not available, the tree will be expanded as much as possible. You can add the protocol prefix ftp://
to any of the above entries.
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;