Re: Can't get attributes of file '/'.
Thanks. I'm sending you an email with a new development version.
It looks like a bug in the FTP server.
...
Do you know what FTP server software is that? So that I can report this to the vendor.
Anyway, you might be able to workaround this using:SessionOptions.AddRawSettings("FtpUseMlsd", "1");
There was a problem in FtpQTS(): WinSCP.SessionRemoteException: Can't get attributes of file '/'. ---> WinSCP.SessionRemoteException: Could not retrieve file information Invalid number of arguments SIZE --- End of inner exception stack trace --- at WinSCP.OperationResultBase.Check() at FTP_Check4Files.FTP_Check4Files.FtpQTS(String localPath, String remotePath)
/
), it responds with information on ftpuser
folder.
/home/ftpuser
.
SessionOptions.AddRawSettings("FtpUseMlsd", "1");
Message: Can't get attributes of file '/'.
Stack Trace:
at WinSCP.OperationResultBase.Check() at FTP_Check4Files.FTP_Check4Files.FtpQTS(String localPath, String remotePath)
Message: Can't get attributes of file '/'.
Stack Trace: at WinSCP.OperationResultBase.Check()
private void qtsTimer_Elapsed(object sender, ElapsedEventArgs e)
{
string localPath = @"U:\CLM";
string remotePath = "/";
MyProgram_eventLog.WriteEntry("Checking the " + remotePath + " with the qtsTimer: " + DateTime.Now.ToString(), EventLogEntryType.Information);
FtpQTS(localPath, remotePath);
}
private void FtpQTS(string localPath, string remotePath)
{
///<summary>The full path of the file on the FTP server.</summary>
string remoteFile;
try
{
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "ftp.comany.com",
UserName = "ftpuser",
Password = "ftppass",
// If using Protocol.Sftp then you would add the following line
// SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
};
MyProgram_eventLog.WriteEntry("A connection to ftpuser on ftpserver has been made", EventLogEntryType.Information);
using (Session session = new Session())
{
//log session
session.SessionLogPath = @"U:\CLM\Logs\WinSCPLog.log";
// Connect
session.Open(sessionOptions);
RemoteDirectoryInfo remoteDirectory = session.ListDirectory(remotePath);
MyProgram_eventLog.WriteEntry("Checking " + remotePath + " on ftpuser ftpserver for new files", EventLogEntryType.Information);
foreach (RemoteFileInfo fileInfo in remoteDirectory.Files)
{
if (fileInfo.Name != "..")
{
remoteFile = remotePath + fileInfo.Name;
MyProgram_eventLog.WriteEntry("A new file has been found: " + fileInfo.Name, EventLogEntryType.Information);
// Download the file and throw on any error
session.GetFiles(remotePath, localPath).Check();
MyProgram_eventLog.WriteEntry("Download to " + localPath + " done", EventLogEntryType.Information);
// Remove the file
session.RemoveFiles(remoteFile);
MyProgram_eventLog.WriteEntry("Removed file: " + remoteFile, EventLogEntryType.Information);
}
else
{
MyProgram_eventLog.WriteEntry("Found " + fileInfo.Name + " which is not a new file", EventLogEntryType.Information);
}
}
}
}
catch (Exception ex)
{
MyProgram_eventLog.WriteEntry("There was a problem in FtpQTS(): " + ex.ToString(), EventLogEntryType.Error);
EmailError(ref ex);
}
}