Can I use Position and Length properties in the Sftp stream?

0
I have downloaded the FTP Expert package and to retrieve data from a remote stream at a specific location I need to specify a parameter. How do I do that in the `Sftp` class? In short, how can I set Position and Length for the stream object returned from the [`GetDownloadStream`][1]/[`GetUploadStream`][2] in the Sftp Client? [1]: http://doc.componentpro.com/ComponentPro-Sftp/ComponentPro-Net-Sftp-GetDownloadStream(System-String) [2]: http://doc.componentpro.com/ComponentPro-Sftp/ComponentPro-Net-Sftp-GetUploadStream(System-String)
edited 12/11/2017 11:04:43 PM
asked 12/11/2017 10:52:11 PM
add a comment

1 Answers

0
The `Sftp` class does not require you to specify the position and length in the `GetDownloadStream` method. Instead, you can normally use the `Seek` of the stream object returned by the `GetDownloadStream` or `GetUploadStream` method. Here is an example of using that method: using System.IO; using ComponentPro.Compression; using ComponentPro.Net; ... // Create a new class instance. using (Sftp client = new Sftp()) { // Connect to the SFTP server. client.Connect("192.168.0.211"); // Authenticate. client.Authenticate("test", "test"); // ... // Get download stream for remote file 'uncompressed.dat'. Stream istream = client.GetDownloadStream("/compressed.z", SeekOrigin.Begin, 1024); // Create new file FileStream fo = new FileStream("d:\\temp\\uncompressed2.dat", FileMode.Create); // Create a new instance of the ZlibInputStream for the compression. ZlibStream zs = new ZlibStream(istream); byte[] buf = new byte[8192]; int read; while ((read = zs.Read(buf, 0, 8192)) > 0) // Read from the download stream. { fo.Write(buf, 0, read); // And write to the compression Zlib stream. } zs.Close(); fo.Close(); // ... }
 
answered 12/12/2017 9:47:14 AM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged sftp ftp or ask your own question.