This documentation is archived and is not being maintained.


Call this member function to store a file on an FTP server.

BOOL PutFile(
   LPCTSTR pstrLocalFile,
   LPCTSTR pstrRemoteFile,
   DWORD_PTR dwContext = 1 



A pointer to a string containing the name of the file to send from the local system.


A pointer to a string containing the name of the file to create on the FTP server.


Specifies the conditions under which the transfer of the file occurs. Can be any of the FTP_TRANSFER_* constants described in OpenFile.


The context identifier for placing the file. See Remarks for more information about dwContext.

Nonzero if successful; otherwise 0. If the call fails, the Win32 function GetLastError may be called to determine the cause of the error.

PutFile is a high-level routine that handles all of the operations associated with storing a file on an FTP server. Applications that only send data, or that require closer control over the file transfer, should use OpenFile and CInternetFile::Write.

Override the dwContext default to set the context identifier to a value of your choosing. The context identifier is associated with this specific operation of the CFtpConnection object created by its CInternetSession object. The value is returned to CInternetSession::OnStatusCallback to provide status on the operation with which it is identified. See the article Internet First Steps: WinInet for more information about the context identifier.

Header: afxinet.h

© 2016 Microsoft