Open
Description
When I want to upload a file, I can either use the method SftpClient.UploadFile
or I can use
using (Stream destinationStream = sftpClient.OpenWrite(destinationPath))
{
byte[] buffer = new byte[10 * 1024 * 1024]; // 10 MB buffer
long totalBytesCopied = 0;
int currentBlockSize = 0;
Progress(totalBytesCopied);
while ((currentBlockSize = fileStream.Read(buffer, 0, buffer.Length)) > 0)
{
destinationStream.Write(buffer, 0, currentBlockSize);
totalBytesCopied += currentBlockSize;
Progress(totalBytesCopied);
}
}
With SftpClient.UploadFile
, there is no problem.
But, if I use the previous code, the performances are very, very, very... very... bad.
And I am sure "fileStream.Read" is not the problem.
The method "Progress" is just a Console.WriteLine.
It seems the SftpFileStream is problematic when we want to upload a file.
Can you please fix this problem ?
Thank you very much.