Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

The Windows Internet Services (WinInet) functions enable applications to navigate and manipulate directories and files on an FTP server.

To begin an FTP session, use InternetConnectto create the FTP session handle to be used by the FTP functions provided with the WinInet functions.

The WinInet functions provide the following actions on an FTP server:

  • Navigation between directories.

  • Enumerating, creating, removing, and renaming directories.

  • Renaming, uploading, downloading, and deleting files.

Navigation is provided by the FtpGetCurrentDirectoryand FtpSetCurrentDirectoryfunctions. These functions utilize the FTP session handle created by a previous call to InternetConnectto determine which directory the application is currently in, or to change to a different subdirectory.

Directory enumeration is performed by using the FtpFindFirstFileand InternetFindNextFilefunctions. FtpFindFirstFileuses the FTP session handle created by InternetConnectto find the first file that matches the given search criteria and returns a handle to continue the directory enumeration. InternetFindNextFileuses the handle returned by FtpFindFirstFileto return the next file that matches the original search criteria. The application should continue to call InternetFindNextFileuntil there are no more files left in the directory.

Use the FtpCreateDirectoryfunction to create new directories. This function uses the FTP session handle created by InternetConnectand creates the directory specified by the string passed to the function. The string can contain a directory name relative to the current directory, or a fully qualified directory path.

To rename either files or directories, the application can call FtpRenameFile. This function replaces the original name with the new name passed to the function. The name of the file or directory can be relative to the current directory, or a fully qualified name.

To upload or place files on an FTP server, the application can use either FtpPutFileor FtpOpenFile(along with InternetWriteFile). FtpPutFilecan be used if the file already exists locally, while FtpOpenFileand InternetWriteFilecan be used if data needs to be written to a file on the FTP server.

To download or get files, the application can use either FtpGetFileor FtpOpenFile(with InternetReadFile). FtpGetFileis used to retrieve a file from an FTP server and store it locally, while FtpOpenFileand InternetReadFilecan be used to control where the downloaded information is going (for example, the application could display the information in an edit box).

Delete files on an FTP server by using the FtpDeleteFilefunction. This function removes a file name that is relative either to the current directory or to a fully qualified file name from the FTP server. FtpDeleteFilerequires an FTP session handle returned by InternetConnect.

For more information about FTP sessions, see the following topics:

See Also