Dart.Ssh Namespace > Sftp Class > Get Method : Get(String,Int64) Method |
'Declaration Public Overloads Function Get( _ ByVal fileName As String, _ ByVal offset As Long _ ) As Stream
/// <summary> /// Downloads the specified remote file to the local path. /// </summary> /// <param name="mySftp">A connected and authenticated instance of the Sftp class</param> /// <param name="remotePath">Relative or absolute path to the file on the server</param> /// <param name="localPath">Local path to download the file to</param> private static void sftpGetWithStream(Sftp mySftp, string remotePath, string localPath) { using (FileStream output = File.Create(localPath)) { using (Stream input = mySftp.Get(remotePath, 0)) { long total = 0; byte[] buffer = new byte[32000]; int read = -1; while (read != 0) { read = input.Read(buffer, 0, 32000); total += read; output.Write(buffer, 0, read); } output.Flush(); } } }
''' <summary> ''' Downloads the specified remote file to the local path. ''' </summary> ''' <param name="mySftp">A connected and authenticated instance of the Sftp class</param> ''' <param name="remotePath">Relative or absolute path to the file on the server</param> ''' <param name="localPath">Local path to download the file to</param> Private Shared Sub sftpGetWithStream(ByVal mySftp As Sftp, ByVal remotePath As String, ByVal localPath As String) Using output As FileStream = File.Create(localPath) Using input As Stream = mySftp.Get(remotePath, 0) Dim total As Long = 0 Dim buffer(31999) As Byte Dim read As Integer = -1 Do While read <> 0 read = input.Read(buffer, 0, 32000) total += read output.Write(buffer, 0, read) Loop output.Flush() End Using End Using End Sub