Topic "Session.GetFiles fails with "Can't get attributes of file""

Author Message
Antony Perkov
[View user's profile]

Joined: 2012-09-27
Posts: 2
I'm automating WinScp (version 5.1.0.0) from a C# program.

My code works successfully with a number of FTP servers, but fails to download files from an NcFTPd server. Interestingly I can download files via the WinScp GUI without any problems.

A small repro case is below. The call to Session.GetFiles fails with "Can't get attributes of file".

var sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
FtpMode = FtpMode.Passive,
FtpSecure = FtpSecure.None,
HostName = "...",
PortNumber = 21,
UserName = "...",
Password = "..."
};

var transferOptions = new TransferOptions
{
PreserveTimestamp = true,
TransferMode = TransferMode.Binary
};

using (var session = new Session())
{
session.SessionLogPath = "WinScpLog.txt";

session.Open(sessionOptions);

var remoteDirectoryInfo = session.ListDirectory(".");
var firstFileName = remoteDirectoryInfo.Files.First(x => !x.IsDirectory).Name;

session.GetFiles(firstFileName, ".", false).Check();
}

I'll send a full session log by email, but the relevant snippet seems to be as follows:

> 2012-09-27 12:41:04.493 Script: get -nopermissions -preservetime -transfer="binary" -- "SomeFile.txt" "."
. 2012-09-27 12:41:04.494 Listing file "SomeFile.txt".
. 2012-09-27 12:41:04.494 Retrieving file information...
> 2012-09-27 12:41:04.494 MLST SomeFile.txt
< 2012-09-27 12:41:07.786 500 Syntax error, command unrecognized.
. 2012-09-27 12:41:07.786 Could not retrieve file information
< 2012-09-27 12:41:07.786 Script: Can't get attributes of file 'SomeFile.txt'.
< 2012-09-27 12:41:07.787 Script: Could not retrieve file information
< 2012-09-27 12:41:07.787 Syntax error, command unrecognized.
. 2012-09-27 12:41:07.787 Script: Failed
> 2012-09-27 12:41:11.959 Script: exit
. 2012-09-27 12:41:11.959 Script: Exit code: 1
. 2012-09-27 12:41:11.962 Disconnected from server
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Please attach a complete log file.
_________________
Martin Prikryl
Antony Perkov
[View user's profile]

Joined: 2012-09-27
Posts: 2
Hi Martin,

Thanks for the response.

I sent you the full log via email as per the instructions at https://winscp.net/eng/docs/reporting

Ant.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
In the log, I can see your server claims to support MLST command, yet it rejects it with "500 Syntax error, command unrecognized.". Looks like a server-side bug.

< 2012-09-27 12:41:00.800 211-Extensions supported:
< 2012-09-27 12:41:00.800 CLNT
< 2012-09-27 12:41:00.800 LANG EN*
< 2012-09-27 12:41:00.810 MDTM
< 2012-09-27 12:41:00.810 MFMT
< 2012-09-27 12:41:00.810 MLST Type*;Size*;Modify*;Perm;Unique;UNIX.mode*;UNIX.owner;UNIX.uid;UNIX.group;UNIX.gid;
< 2012-09-27 12:41:00.810 PASV
< 2012-09-27 12:41:00.810 REST STREAM
< 2012-09-27 12:41:00.810 SIZE
< 2012-09-27 12:41:00.810 UTF8
< 2012-09-27 12:41:00.810 TVFS
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