FVSDK_ERROR_CODE FVSDK_ReadFile(FVSDK_Session* pSession, PBYTE pBuffer, int* pnBufferSize);
Reads data from the file opened with FVSDK_OpenFile() or FVSDK_OpenFileRW(). FTP Voyager SDK buffers the data until the caller retrieves the data from FVSDK. When using this function, the caller should quickly and continually make calls to this function to avoid large memory use by FTP Voyager SDK.
pSession
A pointer to the FVSDK_Session that is to perform the operation.
pBuffer
A pointer to a buffer in which to copy the data from the file.
pnBufferSize
A pointer to the size, in bytes, of the pBuffer parameter to this function. When this function returns, pnBufferSize will contain the amount of data read from the file. If data is read from the file, this value will be greater than zero.
FVSDK_YES if the function was successful; FVSDK_NO if the file contains no more data. Error codes can be found in FVSDK_ErrorCodes.h.
CStdioFile File;
FVSDK_Session* pSession;
CString sRemoteName;
// ... download preparation ...
// attempt to open the file to be downloaded
if (FVSDK_OpenFile(pSession, sRemoteName, TRUE, 0) == FVSDK_YES) {
BYTE Buffer[1024];
int nBytes = sizeof(Buffer);
// read all of the data from the remote file, and write it to the local file
while (FVSDK_ReadFile(pSession, Buffer, &nBytes) == FVSDK_YES) {
// write the data to the local file
File.Write(Buffer, nBytes);
// reset the buffer size
nBytes = sizeof(Buffer);
} // while
// close the remote file
if (FVSDK_CloseFile(pSession) != FVSDK_YES)
AfxMessageBox("Unable to close the remote file.", MB_ICONEXCLAMATION);
} // if
else
AfxMessageBox("Unable to open the remote file.", MB_ICONEXCLAMATION);
// ... download cleanup ...