Subject: method Sftp.GetDownloadStream(String) returns incorrect stream
Date: 2010-12-23 11:38:01
From: Pavel Bronnikov
Source: method-sftp-getdownloadstream-string-returns-incorrect-stream
----------------------------------------------------------------------

When I read data from stream returned byGetDownloadStream method, Stream.Read returns invalid value.

See an example:
static
void Main(string[] args)

{

       Sftp client = new Sftp();

       client.Connect("localhost", 22);

       client.Authenticate("TestUser", "Masterkey");

       var inStream = client.GetDownloadStream("/TestFolder/TestFile.txt");

 

       var buffer = new byte[4096];

       while (true)

       {

              int readed = inStream.Read(buffer, 0, buffer.Length);

 

              //Real file size is 388 bytes, buffer contains correct data, but reade = 163840(dec).

              if (readed <= 0)

              {

                     return;

              }

 

              var str = System.Text.Encoding.UTF8.GetString(buffer);

              Console.WriteLine(str);

       }

}

Why "readed" variable contains 163840 instead of 388?

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index