Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

radha.mukkai

Re: Can't get attributes of file error using C#

Thanks a ton! That fixed it.

I truly appreciate the fast turnaround on my request.

Thanks,
Radha Mukkai

martin wrote:

This is a known bug in an ancient version of VShell.
See https://winscp.net/forum/viewtopic.php?t=2576

You can workaround it by forcing SFTP protocol version 3.

mSessionOptions.AddRawSettings("SFTPMaxVersion", "3");
martin

Re: Can't get attributes of file error using C#

This is a known bug in an ancient version of VShell.
See https://winscp.net/forum/viewtopic.php?t=2576

You can workaround it by forcing SFTP protocol version 3.

mSessionOptions.AddRawSettings("SFTPMaxVersion", "3");
radha.mukkai

Can't get attributes of file error using C#

I am having an issue downloading files from a SFTP server using WinSCP Version 5.7.1. I am automating the download using SSIS. To make troubleshooting easier, I created a simple C# WinForms (Visual Studio 2012; .NET Framework 4.5) to reproduce the issue. The WinForms is hosted on Windows Server 2008 R2. I am able to download files manually using the GUI.

I have looked in the forums and could not find anything conclusive. I am attaching the error log using the C# Winforms app and the success log using the GUI. I have attached the C# code I am using in WinForms (the WinSCP dll has been installed on the GAC on the Windows server).

Per the system administrator, the SFTP server is a Windows-based server. I believe the server is Windows 2000 (not a typo!) running VSHELL from Vandyke software.

I am reproducing the key lines from the error session log below:

> 2015-05-28 16:23:19.605 Script: get -nopermissions -preservetime -transfer="binary" -- "/TestExcelFile.xlsx" "C:\Users\XXXX.XXXX\Desktop\Test\TestExcelFile2015052816242316.xlsx"
. 2015-05-28 16:23:19.606 Listing file "/TestExcelFile.xlsx".
> 2015-05-28 16:23:19.606 Type: SSH_FXP_LSTAT, Size: 32, Number: 1287
< 2015-05-28 16:23:19.606 Type: SSH_FXP_STATUS, Size: 34, Number: 1028
. 2015-05-28 16:23:19.606 Discarding reserved response
< 2015-05-28 16:23:19.610 Type: SSH_FXP_STATUS, Size: 42, Number: 1287
< 2015-05-28 16:23:19.610 Status code: 5, Message: 1287, Server: The handle is invalid. , Language: en
< 2015-05-28 16:23:19.610 Script: Can't get attributes of file '/TestExcelFile.xlsx'.
< 2015-05-28 16:23:19.611 Script: Bad message (badly formatted packet or protocol incompatibility).
< 2015-05-28 16:23:19.611 Error code: 5
< 2015-05-28 16:23:19.611 Error message from server (en): The handle is invalid.
. 2015-05-28 16:23:19.611 Script: Failed
> 2015-05-28 16:23:20.470 Script: exit
. 2015-05-28 16:23:20.470 Script: Exit code: 1
. 2015-05-28 16:23:20.470 Closing connection.
. 2015-05-28 16:23:20.470 Sending special code: 12
. 2015-05-28 16:23:20.470 Sent EOF message