Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Can't get attributes of file '/'.

Thanks. I'm sending you an email with a new development version.
codenat

Re: Can't get attributes of file '/'.

Well, unfortunately, the new .dll and .exe didn't seem to work.
Attached is the log file.
codenat

Re: Can't get attributes of file '/'.

martin wrote:

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.

Thanks for your quick response! IPSwitch File Transfer WS_FTP Server is what it uses.

martin wrote:

Anyway, you might be able to workaround this using:
SessionOptions.AddRawSettings("FtpUseMlsd", "1");

As of 15.04.16, it ran again with the addition of the above line of code. Received a similar error once again and the file did not get transferred. I am attaching the log of today's try. Here is the error:
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)
martin

Re: Can't get attributes of file '/'.

It looks like a bug in the FTP server.
When WinSCP asks it for a details on the root folder (/), it responds with information on ftpuser folder.
It's likely because the FTP root is physically a path like /home/ftpuser.
But the FTP server should completely isolate the client from that, let alone that this is a security flaw.
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");

This sets Use MLSD command for directory listing option to Off.
https://winscp.net/eng/docs/ui_login_ftp
codenat

Re: Can't get attributes of file '/'.

Sorry ... I must've gotten my logs confused. Attached is the log with the error.

Full error:
Message: Can't get attributes of file '/'.
Stack Trace:
at WinSCP.OperationResultBase.Check() at FTP_Check4Files.FTP_Check4Files.FtpQTS(String localPath, String remotePath)
martin

Re: Can't get attributes of file '/'.

There's no "Can't get attributes of file '/'." error in the log. Are you sure you have attached a correct log file? What it is a full call stack of the exception? Do you know what line of a code throws the exception?
codenat

Can't get attributes of file '/'.

Hi,
I have written a Windows service that periodically checks the FTP for new files. When it finds a file, it FTPs the file to another server. The first time it found a file, I received this error:
Message: Can't get attributes of file '/'.
Stack Trace: at WinSCP.OperationResultBase.Check()

I am attaching a log of the event.

Here is the method that I am using:
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);
    }
}

Thanks for your help.