FtpCreateFileW function (wininet.h)

Syntax

HINTERNET FtpCreateFileW(
  HINTERNET hConnect,
  LPCWSTR   lpszFileName,
  DWORD    dwFlags,
  DWORD    dwAttributes,
  DWORD    dwAccess,
  LPVOID   lpvReserved,
  DWORD    dwContext
);

This function is declared in Wininet.h.

Parameters

Parameter Description
hConnect A handle to an FTP session established by a call to InternetConnect.
lpszFileName A pointer to a null-terminated string that contains the name of the file to be created on the FTP server.
dwFlags Flags that control the behavior of the function. Can be 0 or one or more of the following values:
  • FTP_TRANSFER_TYPE_ASCII: Transfers the file in ASCII mode.
  • FTP_TRANSFER_TYPE_BINARY: Transfers the file in binary mode.
  • FTP_TRANSFER_TYPE_UNKNOWN: Transfers the file in automatic mode, where the transfer type is determined by the server.
dwAttributes Specifies the file attributes for the new file. For a list of possible values, see the dwFlags parameter of the CreateFile function. This parameter is optional and can be set to FILE_ATTRIBUTE_NORMAL if no specific attributes are required.
dwAccess Access to the file. This parameter can be GENERIC_WRITE.
lpvReserved This parameter is reserved and must be NULL.
dwContext The application-defined context value with which the Internet functions associate this request. This parameter is used to return asynchronous data to the application.

Return value

Returns a valid handle to the created file if successful, or NULL otherwise. To get a specific error message, call GetLastError.

Remarks

The FtpCreateFileW function creates a file on an FTP server. The function returns a handle to the created file. You can then use this handle to write data to the file using functions like InternetWriteFile. When you are finished with the file, close the handle by calling InternetCloseHandle.

The dwFlags parameter determines the transfer type. If dwFlags is 0, the transfer type is automatically determined by the server.

The dwAttributes parameter can be used to specify file attributes, such as whether the file is compressed or hidden. If no specific attributes are required, set this parameter to FILE_ATTRIBUTE_NORMAL.

Note: This function creates a new file. If a file with the same name already exists on the server, it will typically be overwritten. For more control over file creation and overwriting behavior, consider using the dwCreationDisposition parameter in a lower-level file operation if your FTP protocol supports it.

Requirements

Description
Minimum supported client Windows XP with SP2, Windows Vista or Windows 7.
Minimum supported server Windows Server 2003 with SP1, Windows Server 2008 or Windows Server 2008 R2.
Header wininet.h
Library wininet.lib
DLL wininet.dll
Unicode and ANSI names FtpCreateFileW (Unicode) and FtpCreateFileA (ANSI).

See also