Subject: DownloadFile with stream
Date: 2020-03-02 13:01:23
From: lcobian
Source: downloadfile-stream
----------------------------------------------------------------------

Hello!

I am in the process of testing the sftp component. Works fine but I'm having a strange problem when downloading a file to a file stream.

sftpClient.DownloadFile(fileName, destinationFile); //string to string. This works fine 

BUT

 using (var stream = File.Open(destinationFile, System.IO.FileMode.Create,System.IO.FileAccess.Write, System.IO.FileShare.None))

{
    
sftpClient.DownloadFile(fileName, stream); 

}

results in an exception "Object reference not set to an instance of an object.".

The stream is created fine but shows 0 b after the exception, of course. What am I doing wrong?

----------------------------------------------------------------------

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