Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Downloadind file over SFTP is slow

$
0
0
I am using the following code to download file with secure FTP and the performance is 4-5 times
slower than WinSCP.
        var    client_ = new SftpClient(
                settings_.ServerAddress, 
                settings_.Username, 
                settings_.Password);
            client_.BufferSize = 8 * 1024;
            client_.Connect();
            using (FileStream file = File.Create(path))
            using (SftpFileStream sftpFileStream = 
            client_.OpenRead(String.Format("{0}\{1}",
                            settings_.RemoteFolder,settings_.RemoteFileName)))
            {
                int BUFFER_SIZE = 1024 * 4;
                byte[] buffer = new byte[BUFFER_SIZE];
                int readBytes = sftpFileStream.Read(buffer, 0, BUFFER_SIZE);
                double totalTransferedBytes = (double)readBytes;
                while (readBytes > 0)
                {
                    file.Write(buffer, 0, readBytes);
                    readBytes = sftpFileStream.Read(buffer, 0, BUFFER_SIZE);

                }
            }

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>