Topic "[.Net Assembly] Invalid number of arguments MLST"

Author Message
glacierlee
[View user's profile]

Joined: 2017-04-28
Posts: 7
Location: I am who I am
I am currently using the .Net library to download files from my application. However, I encountered the following issue during the FTP download.

I tried to download the file through Filezilla Client with no problem.

Library Version: 5.9.4
Protocol: FTP
Error message:
Can't get attributes of file '/teck/csv/serials_incremental_27_04_2017 11_43_31.csv'.
Could not retrieve file information
Invalid number of arguments MLST



Anybody can tell me how to fix this error? Thank you.

Last edited by glacierlee on 2017-05-12 03:42; edited 3 times in total
ftp.log (7.61 KB) Private file

Description: Full Session Log

Advertisements
glacierlee
[View user's profile]

Joined: 2017-04-28
Posts: 7
Location: I am who I am
I figured out the error was due to an space in the file name, but I have no idea how to resolve it yet.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
_________________
Martin Prikryl
glacierlee
[View user's profile]

Joined: 2017-04-28
Posts: 7
Location: I am who I am
I have attached the full session log, please help to take a look, thanks.



martin wrote:
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
You seem to have tried to quote the path somehow. Did you? What is your code like?

Use just a simple path, no quoting. If that does not work, post a log file for that.
glacierlee
[View user's profile]

Joined: 2017-04-28
Posts: 7
Location: I am who I am
Yes, actually I didn't quote the path initially, but it didn't work. Then I tried to quote the path still no help.

Here is my code after removing the quote, and attached is the log.

Code:


            // Setup session options
            SessionOptions sessionOptions = new SessionOptions
            {
                //Protocol = site.Type == "FTP" ? Protocol.Ftp : Protocol.Sftp,
                HostName = "xxx.xx.xxx.xx",
                UserName = "FTPUser",
                Password = "Password",
                PortNumber = 21,
                Protocol = Protocol.Ftp

            };
           
            using (Session session = new Session())
            {
                try
                {
                    // Connect
                    session.SessionLogPath = "e:\\temp\\ftp.log";
                    session.Open(sessionOptions);
                   
                    var remoteFileInfos = session.EnumerateRemoteFiles("/Inbox/csv", "*.csv", EnumerationOptions.None)
                        .Where(file => !file.IsDirectory)
                            .OrderByDescending(file => file.LastWriteTime);
                    foreach (var remoteFileInfo in remoteFileInfos)
                    {
                        var remoteFile = session.EscapeFileMask(String.Format("{0}", remoteFileInfo.FullName));
                        var localFile = Path.GetFullPath(String.Format("e:\\temp\\{0}", remoteFileInfo.Name));
                        if (!remoteFileInfo.Name.IsNullOrEmpty())
                        {
                            //var transOptions = new TransferOptions();
                            //transOptions.FileMask = remoteFileInfo.Name;
                            session.GetFiles(remoteFile, localFile,false).Check();
                            var archiveFilePath = session.EscapeFileMask("/Inbox/Backup" + "/" + remoteFileInfo.Name);
                            if (session.FileExists(archiveFilePath))
                                session.RemoveFiles(archiveFilePath);
                            session.MoveFile(remoteFile, archiveFilePath);
                        }

                    }
                    session.Close();
                }
                catch (Exception ex)
                {
                    session.Dispose();//Release session
                    txtOutput.Text = $"{ex.Message}\r\n{ex.StackTrace}";
                }
                // Download the selected file

            }




martin wrote:
You seem to have tried to quote the path somehow. Did you? What is your code like?

Use just a simple path, no quoting. If that does not work, post a log file for that.
ftp.log (7.53 KB) Private file

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
Your code is correct. I have successfully tested it against couple of servers.

It looks like a server-side problem/incompatibility. FTP commands should require no quoting.

Are you using the latest version of the server?
_________________
Martin Prikryl
glacierlee
[View user's profile]

Joined: 2017-04-28
Posts: 7
Location: I am who I am
I am not sure, the server is holding by one of our customers.
However, I have tried the .net FtpWebRequest with no problem.


martin wrote:
Your code is correct. I have successfully tested it against couple of servers.

It looks like a server-side problem/incompatibility. FTP commands should require no quoting.

Are you using the latest version of the server?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
Can you post FtpWebRequest log?
https://stackoverflow.com/q/9664650/850848
glacierlee
[View user's profile]

Joined: 2017-04-28
Posts: 7
Location: I am who I am
Sure, below are the codes I tested with FtpWebRequest:
Code:

Uri ftpUri = new Uri("ftp://FTPuser@xxx.xx.xxx.xx/Inbox/csv/serials_incremental_27_04_2017 11_43_31.csv");


FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(ftpUri);

FtpWebResponse ftpResponse = null;

FileStream ftpfile = new FileStream("e:\\temp\\FTP\\serials_incremental_27_04_2017 11_43_31.csv", FileMode.Create);

ftpRequest.Credentials = new NetworkCredential("FTPuser", "Password");

ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;

ftpRequest.UseBinary = true;

ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();

Stream ftpstream = ftpResponse.GetResponseStream();

byte[] ftpbyte = new byte[2048];

int readcout = 0;

readcout = ftpstream.Read(ftpbyte, 0, 2048);

while (readcout > 0)

{

    ftpfile.Write(ftpbyte, 0, readcout);

    readcout = ftpstream.Read(ftpbyte, 0, 2048);

}

ftpfile.Close();

ftpResponse.Close();

ftpstream.Close();




martin wrote:
Can you post FtpWebRequest log?
https://stackoverflow.com/q/9664650/850848
ftp.log (2.71 KB) Private file

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
As you can see in the log, the FtpWebRequest does not quote the path in the RETR command either.

System.Net Information: 0 : [7956] FtpControlStream#61476884 - Sending command [RETR Inbox/csv/serials_incremental_27_04_2017 11_43_31.csv]

What if you set the Method to GetDateTimestamp or GetFileSize?
glacierlee
[View user's profile]

Joined: 2017-04-28
Posts: 7
Location: I am who I am
I tried both methods with no problem. But I get the following error when I tried ListDirectory.

Code:

The remote server returned an error: (501) Syntax error in parameters or arguments.
   at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
   at System.Net.CommandStream.Dispose(Boolean disposing)
   at System.IO.Stream.Close()
   at System.Net.ConnectionPool.Destroy(PooledStream pooledStream)
   at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse)
   at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
   at System.Net.FtpWebRequest.GetResponse()
   at EdiTranslatorTest.frmMain.DownloadFtpByWebRequest() in E:\Work\Development\DOTNET\EDI Hub\Code_NH\EdiTranslatorTest\frmMain.cs:line 187
   at EdiTranslatorTest.frmMain.btnTest_Click(Object sender, EventArgs e) in E:\Work\Development\DOTNET\EDI Hub\Code_NH\EdiTranslatorTest\frmMain.cs:line 40



martin wrote:
As you can see in the log, the FtpWebRequest does not quote the path in the RETR command either.

System.Net Information: 0 : [7956] FtpControlStream#61476884 - Sending command [RETR Inbox/csv/serials_incremental_27_04_2017 11_43_31.csv]

What if you set the Method to GetDateTimestamp or GetFileSize?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
So it's indeed a bug in the server. It behaves inconsistently with different commands.
Advertisements

You can post new topics in this forum






Search

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