Steps in a Typical FTP Client Application to Delete a File
Home | Overview | How Do I
The following table shows the steps you might perform in a typical FTP client application that deletes a file.
Your goal Actions you take Effects
Begin an FTP session. Create a CInternetSession object. Initializes WinInet and connects to server.
Connect to an FTP server. UseCInternetSession::
GetFtpConnection. Returns aCFtpConnection object.
Check to make sure you’re in the right directory on the FTP server. UseCFtpConnection::
GetCurrentDirectory orCFtpConnection::
GetCurrentDirectoryAsURL. Returns the name or URL of the directory you are currently connected to on the server, depending on the member function selected.
Change to a new FTP directory on the server. UseCFtpConnection::
SetCurrentDirectory. Changes the directory you are currently connected to on the server.
Find the first file in the FTP directory. UseCFtpFileFind::FindFile. Finds the first file. Returns FALSE if no files are found.
Find the next file in the FTP directory. UseCFtpFileFind::
FindNextFile. Finds the next file. Returns FALSE if the file is not found.
Delete the file found by FindFile or FindNextFile. UseCFtpConnection::Remove, using the file name returned by FindFile or FindNextFile. Deletes the file on the server for reading or writing.
Handle exceptions. Use theCInternetException class. Handles all common Internet exception types.
End the FTP session. Dispose of theCInternetSession object. Automatically cleans up open file handles and connections.
Nonzero if successful; otherwise 0. If the call fails, the Win32 functionGetLastError may be called to determine the cause of the error.
Parameters
pstrFileName
A pointer to a string containing the file name to remove.
Remarks
Call this member function to delete the specified file from the connected server.
The pstrFileName parameter can be either a partially qualified filename relative to the current directory or fully qualified. A backslash (\) or forward slash (/) can be used as the directory separator for either name. The Remove function translates the directory name separators to the appropriate characters before they are used.