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

Advertisement

Antony Perkov
Joined:
Posts:
2

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

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

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

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

Reply with quote

Advertisement

You can post new topics in this forum