CHttpClient::CreateFile Method  
 
INT CreateFile(
  LPCTSTR lpszRemoteFile,  
  DWORD dwFileLength  
);

The CreateFile method creates the specified file on the server.

Parameters

lpszRemoteFile
Points to a string that specifies the name of the file being created on the server. The client must have the appropriate access rights to create the file or an error will be returned.
dwFileLength
Specifies the length of the file that will be created on the server. This value must be greater than zero.

Return Value

If the method succeeds, the return value is the server result code. If the method fails, the return value is HTTP_ERROR. To get extended error information, call GetLastError.

Remarks

The CreateFile method uses the PUT command to create the file. The server must support this command and the user must have the appropriate permission to create the specified file. If this method is successful, the client should then use the Write method to send the contents of the file to the server. Once all of the data has been written, the CloseFile method should be called to close the file and complete the operation. Note that this method is typically only accepted by servers that support version 1.1 of the protocol or later.

When using Write to send the contents of the file to the server, it is recommended that the data be written in logical blocks that are no larger than 8,192 bytes in size. Attempting to write very large amounts of data in a single call can either cause the thread to block or, in the case of an asynchronous connection, return an error if the internal buffers cannot accommodate all of the data. To send the entire contents of a file in a single method call, use the PutData method instead of calling CreateFile.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtpv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also