簡體   English   中英

WinSCP Session.GetFiles錯誤沒有這樣的文件或目錄

[英]WinSCP Session.GetFiles error No such file or directory

結合使用WinSCP和變量來自動從遠程根文件夾下載特定文件。 我沒有問題,但嘗試下載時代碼會生成錯誤“無此類文件或目錄”。

這是代碼:

' Setup session variables, connect, and download file
Dim remotefile As String = "text.zip"
Dim localpath As String = "D:\Work\Returns\"

Dim sessionOptions As New SessionOptions
With sessionOptions
   .Protocol = Protocol.Sftp
   .HostName = myftpaddress
   .UserName = myftpuser
   .Password = myftppass
   .SshHostKeyFingerprint = SSH         
End With

Using session As New Session
  'go ahead & connect
  session.Open(sessionOptions)

  Dim transferOptions As New TransferOptions
  transferOptions.TransferMode = TransferMode.Binary
  Dim transferResult As TransferOperationResult
  'now get the file
  transferResult = session.GetFiles("/" & remotefile, localpath, False, transferOptions)
End Using

您嘗試下載的文件不存在。

您很可能使用了錯誤的路徑。 您確定帳戶是chroot嗎? 路徑不是/user/home/text.zip而不是/text.zip嗎?

使用WinSCP GUI查找文件的正確路徑。

您甚至可以讓WinSCP GUI為您生成正確的SFTP VB.NET下載代碼


如果這樣做沒有幫助,我們需要查看您的代碼會話日志文件(設置Session.SessionLogPath ),以及顯示相同文件下載的WinSCP GUI日志文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM