INT OpenFile( |
|
LPCTSTR lpszFileName, |
|
|
DWORD dwOpenMode, |
|
|
DWORD dwOffset |
|
); |
The OpenFile method creates or opens the specified file on
the server.
Parameters
- lpszFileName
- Points to a string that specifies the name of
the remote file to create or open. The file pathing and name
conventions must be that of the server.
- dwOpenMode
- Specifies the type of access to the file. An application can
open a file for reading, create a new file or append data to an
existing file. This parameter should be one of the following
values.
Constant |
Description |
FTP_FILE_READ |
The file is opened for reading on the server. A data
channel is created and the contents of the file are returned to
the client. |
FTP_FILE_WRITE |
The file is opened for writing on the server. If the
file does not exist, it will be created. If it does exist, it
will be overwritten. |
FTP_FILE_APPEND |
The file is opened for writing on the server. All
data will be appended to the end of the file. |
- dwOffset
- A byte offset which specifies where the file transfer should
begin. The default value of zero specifies that the file transfer
should start at the beginning of the file. A value greater than
zero is typically used to restart a transfer that has not completed
successfully. Note that specifying a non-zero offset using FTP
requires that the server support the REST command to restart
transfers.
Return Value
If the method succeeds, the return value is the server result
code. If the method fails, the return value is FTP_ERROR. To get
extended error information, call GetLastError.
Remarks
Only one file may be opened at a time for each client session.
Attempting to perform an action such as uploading or downloading
another file while a file is currently open will result in an error.
Typically this indicates that the application failed to call the
CloseFile method.
It is strongly recommended that most applications use the
GetFile or PutFile methods to perform file transfers.
These methods are easier to use, and have internal optimizations that
improves the overall data transfer rate when compared to implementing
the file transfer code in your own application.
When a file is created on the server, the file ownership
and access rights are determined by the server. Some servers may
provide a method to change these attributes through site-specific
commands. Refer to the server's operating system documentation for
more information about what commands may be available.
Requirements
Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csftpv10.lib
Unicode: Implemented as Unicode and ANSI versions.
See Also
CloseFile,
GetFile,
GetFileSize,
GetFileTime,
PutFile,
SetFileTime
|