So a little bit of background, we are trying to use sftpclient to copy a whole directory structure with all files within the directories. It works well with our small sample set of directories and small text files, but when we move on to the real tree with all files (420MB worth) it stops downloading at about 20MB worth.
This is sort of the code we are using - (I'm reconstructing from memory)
This is sort of the code we are using - (I'm reconstructing from memory)
Public Sub getFiles(sServer As String, sUsername As String, sPwd As String)
Dim rSftp As Renci.SshNet.SftpClient
Dim strPath As String
strPath="copy_location"
rSftp = New Renci.SshNet.SftpClient(sServer, sUsername, sPwd)
rSftp.Connect()
If(Not System.IO.Directory.Exists(strPath)) Then
System.IO.Directory.CreateDirectory(strPath)
End If
walkSFTPDirs (rSftp.ListDirectory("./tunnel_pack/"), strPath, rSftp)
rSftp.Disconnect()
End Sub
Public Sub walkSFTPDirs (ByVal dirContent As System.Collections.Generic.IEnumerable(Of renci.SshNet.Sftp.SftpFile), byval strRootPath As String, byval rSftp As Renci.SshNet.SftpClient)
Dim dirItm As renci.SshNet.Sftp.SftpFile
Dim oOutput As System.IO.FileStream
For Each dirItm In dirContent
If dirItm.IsDirectory = True Then
If(Not System.IO.Directory.Exists(strRootPath & "\\" & dirItm.Name)) Then
System.IO.Directory.CreateDirectory(strRootPath & "\\" & dirItm.Name)
walkSFTPDirs(rsftp.ListDirectory(dirItm.FullName),strRootPath & "\\" & dirItm.Name, rsftp)
End If
Else
oOutput = New System.IO.FileStream(strRootPath & "\\" & dirItm.Name,System.IO.FileMode.Create)
rSftp.DownloadFile(dirItm.FullName, oOutput)
oOutput.Close
End If
Next
End Sub
Thanks for any pointers you may provide.