Can't get attributes of file - VB.Net
Here is my VB code.
Imports WinSCP
Private Sub sbSFTPTransfer(strHostName As String, strUserName As String, strPwd As String)
Dim objSession As Session
Dim objSessionOptions As New SessionOptions
Dim objTransferOptions As New TransferOptions
Dim strFullFileName As String = String.Empty
Dim objTransferResult As TransferOperationResult
Try
' Setup session options
With objSessionOptions
.Protocol = Protocol.Sftp
.HostName = strHostName
.UserName = strUserName
.Password = strPwd
.SshHostKeyFingerprint = strFTPImportServerKey
End With
objSession = New Session
objSession.SessionLogPath = "LogFile.txt"
objSession.Open(objSessionOptions)
' Upload files
With objTransferOptions
.TransferMode = TransferMode.Binary
.PreserveTimestamp = False
.ResumeSupport.State = TransferResumeSupportState.Off
End With
objTransferResult = objSession.GetFiles(strHostName, strFTPImportFolder & "pnmpyt.txt", False, objTransferOptions)
'' Throw on any error
objTransferResult.Check()
Catch MyException As System.Exception
Finally
End Try
End Sub
Here is my log file (modified to remove Key file information):
. 2015-04-15 09:28:54.456 --------------------------------------------------------------------------
. 2015-04-15 09:28:54.456 WinSCP Version 5.7.2 (Build 5316) (OS 6.1.7601 Service Pack 1 - Windows 7 Enterprise)
. 2015-04-15 09:28:54.456 Configuration: nul
. 2015-04-15 09:28:54.456 Log level: Normal
. 2015-04-15 09:28:54.456 Local account: domain\user
. 2015-04-15 09:28:54.456 Working directory: x
. 2015-04-15 09:28:54.456 Process ID: 7968
. 2015-04-15 09:28:54.456 Command-line: x /xmlgroups /nointeractiveinput /dotnet=572 /ini=nul /log="LogFile.txt" /console /consoleinstance=_6628_63125272_685
. 2015-04-15 09:28:54.456 Time zone: Current: GMT-6, Standard: GMT-7 (Mountain Standard Time), DST: GMT-6 (Mountain Daylight Time), DST Start: 3/8/2015, DST End: 11/1/2015
. 2015-04-15 09:28:54.456 Login time: Wednesday, April 15, 2015 9:28:54 AM
. 2015-04-15 09:28:54.456 --------------------------------------------------------------------------
. 2015-04-15 09:28:54.456 Script: Retrospectively logging previous script records:
> 2015-04-15 09:28:54.456 Script: option batch on
< 2015-04-15 09:28:54.456 Script: batch on
< 2015-04-15 09:28:54.456 Script: reconnecttime 120
> 2015-04-15 09:28:54.456 Script: option confirm off
< 2015-04-15 09:28:54.456 Script: confirm off
> 2015-04-15 09:28:54.456 Script: option reconnecttime 120
< 2015-04-15 09:28:54.456 Script: reconnecttime 120
> 2015-04-15 09:28:54.456 Script: open sftp://Name-City:***@sftp%3A%2F%2FName-City%2Fpnmpyt.txt%40Server01 -hostkey="ssh-rsa x" -timeout=15
. 2015-04-15 09:28:54.456 --------------------------------------------------------------------------
. 2015-04-15 09:28:54.456 Session name: Name-City@Server01 (Ad-Hoc site)
. 2015-04-15 09:28:54.456 Host name: Server01 (Port: 22)
. 2015-04-15 09:28:54.456 User name: Name-City(Password: Yes, Key file: No)
. 2015-04-15 09:28:54.456 Tunnel: No
. 2015-04-15 09:28:54.456 Transfer Protocol: SFTP
. 2015-04-15 09:28:54.456 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2015-04-15 09:28:54.456 Disable Nagle: No
. 2015-04-15 09:28:54.456 Proxy: none
. 2015-04-15 09:28:54.456 Send buffer: 262144
. 2015-04-15 09:28:54.456 SSH protocol version: 2; Compression: No
. 2015-04-15 09:28:54.456 Bypass authentication: No
. 2015-04-15 09:28:54.456 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2015-04-15 09:28:54.456 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2015-04-15 09:28:54.456 KEX: dh-gex-sha1,dh-group14-sha1,dh-group1-sha1,rsa,WARN
. 2015-04-15 09:28:54.456 SSH Bugs: A,A,A,A,A,A,A,A,A,A,A
. 2015-04-15 09:28:54.456 Simple channel: Yes
. 2015-04-15 09:28:54.456 Return code variable: Autodetect; Lookup user groups: A
. 2015-04-15 09:28:54.456 Shell: default
. 2015-04-15 09:28:54.456 EOL: 0, UTF: 2
. 2015-04-15 09:28:54.456 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2015-04-15 09:28:54.456 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2015-04-15 09:28:54.456 SFTP Bugs: A,A
. 2015-04-15 09:28:54.456 SFTP Server: default
. 2015-04-15 09:28:54.456 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2015-04-15 09:28:54.456 Cache directory changes: Yes, Permanent: Yes
. 2015-04-15 09:28:54.456 DST mode: 1
. 2015-04-15 09:28:54.456 --------------------------------------------------------------------------
. 2015-04-15 09:28:54.456 Looking up host "Server01"
. 2015-04-15 09:28:54.456 Connecting to 172.31.40.70 port 22
. 2015-04-15 09:28:54.472 Server version: SSH-2.0-5.25 FlowSsh: Bitvise SSH Server (WinSSHD) 6.07
. 2015-04-15 09:28:54.472 Using SSH protocol version 2
. 2015-04-15 09:28:54.472 We claim version: SSH-2.0-WinSCP_release_5.7.2
. 2015-04-15 09:28:54.472 Doing Diffie-Hellman group exchange
. 2015-04-15 09:28:54.675 Doing Diffie-Hellman key exchange with hash SHA-256
. 2015-04-15 09:28:54.862 Verifying host key x
. 2015-04-15 09:28:54.862 Host key matches configured key
. 2015-04-15 09:28:54.862 Host key fingerprint is:
. 2015-04-15 09:28:54.862 ssh-rsa x
. 2015-04-15 09:28:54.862 Initialised AES-256 SDCTR client->server encryption
. 2015-04-15 09:28:54.862 Initialised HMAC-SHA-256 client->server MAC algorithm
. 2015-04-15 09:28:54.862 Initialised AES-256 SDCTR server->client encryption
. 2015-04-15 09:28:54.862 Initialised HMAC-SHA-256 server->client MAC algorithm
! 2015-04-15 09:28:55.080 Using username "Name-City".
. 2015-04-15 09:28:55.096 Prompt (password, "SSH password", <no instructions>, "&Password: ")
. 2015-04-15 09:28:55.096 Using stored password.
. 2015-04-15 09:28:55.114 Sent password
. 2015-04-15 09:28:55.114 Access granted
. 2015-04-15 09:28:55.114 Opening session as main channel
. 2015-04-15 09:28:55.114 Opened main channel
. 2015-04-15 09:28:55.364 Started a shell/command
. 2015-04-15 09:28:55.364 --------------------------------------------------------------------------
. 2015-04-15 09:28:55.364 Using SFTP protocol.
. 2015-04-15 09:28:55.364 Doing startup conversation with host.
> 2015-04-15 09:28:55.364 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2015-04-15 09:28:55.364 Type: SSH_FXP_VERSION, Size: 22, Number: -1
. 2015-04-15 09:28:55.364 SFTP version 6 negotiated.
. 2015-04-15 09:28:55.364 Server requests EOL sequence "\r\n".
. 2015-04-15 09:28:55.364 We will use UTF-8 strings as it is mandatory with SFTP version 4 and newer
. 2015-04-15 09:28:55.364 Getting current directory name.
. 2015-04-15 09:28:55.364 Getting real path for '.'
> 2015-04-15 09:28:55.364 Type: SSH_FXP_REALPATH, Size: 11, Number: 16
< 2015-04-15 09:28:55.364 Type: SSH_FXP_NAME, Size: 75, Number: 16
. 2015-04-15 09:28:55.364 Real path is '/'
. 2015-04-15 09:28:55.364 Startup conversation with host finished.
< 2015-04-15 09:28:55.364 Script: Active session: [1] Name-City@Server01
> 2015-04-15 09:28:55.769 Script: pwd
< 2015-04-15 09:28:55.769 Script: /
> 2015-04-15 09:28:56.034 Script: get -nopermissions -nopreservetime -transfer="binary" -resumesupport="off" -- "sftp://Name-City/pnmpyt.txt@Server01" "C:\Windows\Temp\pnmpyt.txt"
. 2015-04-15 09:28:56.034 Listing file "sftp://File-City/pnmpyt.txt@Server01".
> 2015-04-15 09:28:56.034 Type: SSH_FXP_LSTAT, Size: 52, Number: 263
< 2015-04-15 09:28:56.034 Type: SSH_FXP_STATUS, Size: 50, Number: 263
< 2015-04-15 09:28:56.034 Status code: 4, Message: 263, Server: The requested operation failed., Language: en
< 2015-04-15 09:28:56.034 Script: Can't get attributes of file 'sftp://File-City/pnmpyt.txt@Server01'.
< 2015-04-15 09:28:56.050 Script: General failure (server should provide error description).
< 2015-04-15 09:28:56.050 Error code: 4
< 2015-04-15 09:28:56.050 Error message from server (en): The requested operation failed.
. 2015-04-15 09:28:56.050 Script: Failed
I've done a lot of searching of the error message over the past three days and can't seem to find an answer that applies in my case.