Discuss this help topic in SecureBlackbox Forum

SFTP: Read part of remote file

To read part of the remote file, use OpenFile/ Read/ CloseHandle sequence of methods of TElSimpleSFTPClient class.

Use OpenFile() method of TElSimpleSFTPClient class to open the file and get a file handle. The methods accept the absolute path to the remote file in the "/path/to/file.ext" form (SFTP doesn't have a concept of "current directory") as a parameter.

The next step is to use Read() method to transfer the data. Don't pass the whole data block to this method. Use chunks which are smaller than 1 Mb. Read() method accepts Offset as a parameter, letting you specify the offset in the file, where the data is read from.

When you finish reading the data, use CloseHandle() method to close the file.

All of the above methods are synchronous and return when the operation is completed.

For information about error handling, see the corresponding how-to article.

How To articles about SFTP client

Discuss this help topic in SecureBlackbox Forum