Developing an FTP client with the WinInet Api (i)

Source: Internet
Author: User
Tags sessions win32 ftp client
FTP Sessions
FTP Session
The Win32 Internet functions can is used to provide applications with the ability to navigate and manipulate directories a nd files on a FTP server. Applications that use a CERN proxy exclusively must use the InternetOpenUrl function because CERN proxies does not support F Tp. For more information on the How to use InternetOpenUrl, the accessing URLs directly.
Win32 Internet functions provide applications with the ability to browse and manipulate files and directories on an FTP server.


To begin a session of FTP, use InternetConnect to create the valid FTP sessions handle to is used by the FTP functions Provid Ed with the Win32 Internet functions.
to start an FTP session, you need to create a valid FTP session handle with the InternetConnect command of the Win32 Internet function.


The Win32 Internet functions provide the capability to navigate between; Enumerate, create, remove, and rename directories; and rename, upload, download, and delete files on a FTP server.
these Win32 Internet functions provide the ability to manipulate directories on an FTP server such as navigating between directories, enumerating directories, building directories, deleting directories, renaming directories, and manipulating files such as changing file names, updating, downloading, and deleting files.


Navigation is provided by the ftpgetcurrentdirectory and Ftpsetcurrentdirectory functions. These functions utilize the FTP sessions handle created by a previous call to InternetConnect to determine which directory The application is currently with or to a different subdirectory.
The ftpgetcurrentdirectory and ftpsetcurrentdirectory functions are used for navigating between directories. These functions use the FTP session handle created by the InternetConnect function to detect the current directory where the application is in, or to change the current directory to a different subdirectory.


Directory enumeration is performed by using the Ftpfindfirstfile and Internetfindnextfile functions. Ftpfindfirstfile uses the FTP session handle created by InternetConnect to find the ' the ' the ' the ' the ' the ' matches given CH criteria and returns a handle to continue the directory enumeration. Internetfindnextfile uses the handle returned by Ftpfindfirstfile to return the next file that matches the original search Criteria. The application should continue to call Internetfindnextfile until there no further files in the directory.
you can get a list of directories by executing the ftpfindfirstfile and Internetfindnextfile functions. Ftpfindfirstfile also uses the FTP session handle created by InternetConnect to locate the first qualifying file and returns a handle to continue enumerating the directories. Internetfindnextfile Use this handle to return the next eligible file. The program can continue to use internetfindnextfile until there are no eligible files in the current directory.


The NEW directories are created by using the Ftpcreatedirectory function. This function uses the FTP sessions handle created by InternetConnect and creates the directory specified by the string pas Sed to the function. The string can contain a directory name relative to the current directory, or a fully qualified directory path.
You can use the Ftpcreatedirectory function to create a new directory. This function creates a directory using the FTP session handle created by InternetConnect and a specified string. The string can be a directory name for a relative path, or it can be a complete path.


To rename either files or directories, the application can call Ftprenamefile. This function replaces the original name and the new name passed to the function. The name of the file or directory can is relative to the current directory, or a fully qualified name.
to rename a file or directory, you can use the Ftprenamefile function. This function replaces the original name with the new name. The new file or directory name can use a relative path or use the full path.


To upload or place files on a FTP server, the application can use either FtpPutFile or FtpOpenFile (along with INTERNETWR Itefile). FtpPutFile can is used if the file already exists locally, while FtpOpenFile and InternetWriteFile can is used if data nee DS to is written to a file on the FTP server.
If you need to update files on an FTP server online, you can use either FtpPutFile or FtpOpenFile (to match internetwritefile). FtpPutFile is used to hold the file locally while FtpOpenFile and internetwritefile are used when the file needs to be updated online.


To download or get files, the application can-either FtpGetFile or FtpOpenFile (with InternetReadFile). FtpGetFile is used to retrieve a file in FTP server and store it locally, while FtpOpenFile and InternetReadFile can be used to control where the downloaded information are going (for example, it could being used to display the information in an edit box).
Download files can be used with FtpGetFile or ftpopenfile (with InternetReadFile). FtpGetFile are used to download files from the FTP server to the local, while FtpOpenFile and internetreadfile can be used for control during downloading. For example, it can display some information about downloads in an edit box.


Deleting files on a FTP server is do by using the Ftpdeletefile function. This function removes a file name of either relative to the current directory or a fully qualified file name from the FTP server. Ftpdeletefile requires an FTP sessions handle returned by InternetConnect.
the Ftpdeletefile function is used to delete files. This function deletes files from the current directory or files that contain the full path from the server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.