Re: [.Net Assembly] Invalid number of arguments MLST
So it's indeed a bug in the server. It behaves inconsistently with different commands.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
ListDirectory
.
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
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]
Method
to GetDateTimestamp
or GetFileSize
?
FtpWebRequest
:
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();
FtpWebRequest
with no problem.
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
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())
{
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
}
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.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