我需要通过SFTP获取所有文件名列表。我正在尝试将它放在ArrayList中,但不确定要使用的命令..
Public Shared Function Retrieve_Directory_list(ByVal strHost As String, _
ByVal strUsername As String, _
ByVal strPassword As String, _
ByVal strFtpFilePath As String, _
ByVal strlocalFilePath As String) As ArrayList)
Dim sshCp As SshTransferProtocolBase
Dim res As New ArrayList()
sshCp = New Sftp(strHost, strUsername, strPassword)
sshCp.Connect()
'res = sshCp.???
sshCp.Close()
Return res
End Function
如果您还有其他需要,请告诉我。谢谢!
答案 0 :(得分:0)
我想你想要这样的东西:
sshCp.Connect()
Dim result as ArrayList() = sshCp.GetFileList("/foldername")
sshCp.Close()
Return res
答案 1 :(得分:0)
您可能希望查看Tamir.SharpSsh.Sftp.GetFileList(String path),它返回表示远程文件的IEnumerable对象。它应该能够做你想要的。
https://bitbucket.org/mattgwagner/sharpssh/src/260e9d6d1bcf/SharpSSH/Sftp.cs