0 votes
by (2.0k points)

Rebex FTP client support location, length parameters in GetDownloadStream / GetUploadStream functions.
This is very useful for me.
Can SFTP clients support these parameters in GetDownloadStream / GetUploadStream?
Or please tell me what alternatives are available.

My ftp upload/download Codes are:

var stream = client.GetDownloadStream(path, position, length);
while(stream != null)
{
int len = stream.Read(buffer, 0, 8192);
if(len == 0)
break;
WriteToMyCustomCacheFile(buffer, len);
}
stream.Close();

var stream = client.GetUploadStream(path, position, length);
while(stream != null)
{
int len = ReadFromMyCustomFile(buffer, 8192);
if(len == 0)
break;
stream.Write(buffer, 0, len);
}
stream.Close();

PS : I can not found Rebex.IO.PIPE (Trial version).

Applies to: Rebex SFTP

1 Answer

+1 vote
by (72.7k points)
selected by
 
Best answer

The additional parameters are not necessary in SFTP.

Unlike FTP, the stream returned by SFTP is fully seekable. So, instead:

var stream = client.GetDownloadStream(path, position, offset);

you can do this:

var stream = client.GetDownloadStream(path);
stream.Seek(offset, position);
by (2.0k points)
Thank you very much.
...