Topic "Can't get attributes of file error using C#"

Author Message
radha.mukkai
[View user's profile]

Joined: 2015-05-28
Posts: 2
Location: Charlotte, NC
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
SFTPTest.cs (3.92 KB) [Download]

Description: (none)

SFTP_TransferSuccess_GUI.txt (3.81 KB) [Download]

Description: (none)

SFTP_TransferError_CSharpWinforms_Automation.log (10.09 KB) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
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
[View user's profile]

Joined: 2015-05-28
Posts: 2
Location: Charlotte, NC
Thanks a ton! That fixed it.

I truly appreciate the fast turnaround on my request.

Thanks,
Radha Mukkai

prikryl 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");
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License