2017-05-09 13 views
0

WinSCP를 변수와 함께 사용하여 원격 루트 폴더에서 특정 파일을 자동 다운로드합니다. 연결에 문제가 없지만 다운로드를 시도 할 때 'No such file or directory'오류가 발생합니다.WinSCP Session.GetFiles error 해당 파일 또는 디렉터리가 없습니다.

' 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 

답변

0

다운로드하려고하는 파일이 존재하지 않습니다

여기에 코드입니다.

잘못된 경로가 가장 많이 사용됩니다. 계정이 chroot되었는지 확실합니까? 경로가 /text.zip이 아닌 /user/home/text.zip이 아닌가요?

WinSCP GUI를 사용하여 파일의 올바른 경로를 찾습니다.

WinSCP GUI generate the correct SFTP VB.NET download code for you도있을 수 있습니다. 이 방법으로 문제가 해결되지 않으면


, 우리는 코드 세션 로그 파일 (Session.SessionLogPath 설정)뿐만 아니라, 같은 파일의 다운로드를 보여주는 WinSCP에 GUI 로그 파일을 참조 할 필요가있다.

+0

설명서에 따라 : "파일 전송 코드를 생성하는 대화 상자를 열려면 : (전송) 옵션> [전송 옵션] 대화 상자 (https://winscp.net/eng/)에서 코드 전송 * 명령을 사용하십시오. docs/ui_copy) " –

+0

그리고 도움을 더 원한다면 로그를 보여주세요! –

+0

알았어요, 마틴. 고맙습니다. 코드 생성 기능 사용에 대한 귀하의 제안은 무엇입니까? 어떤 이유로 그것은 로컬 경로에 "*"를 추가 할 것을 제안했습니다. 이상하지만 작동합니다. :) – TheoH