Can't get attributes of file '/'.

Advertisement

codenat
Joined:
Posts:
12
Location:
Columbia, SC

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.
Description: WinSCP Session Log

Reply with quote

Advertisement

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

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?

Reply with quote

codenat
Joined:
Posts:
12
Location:
Columbia, SC

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)

Reply with quote

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

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

Reply with quote

codenat
Joined:
Posts:
12
Location:
Columbia, SC

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)
Description: Log with error from today's run after adding the recommended

Reply with quote

Advertisement

codenat
Joined:
Posts:
12
Location:
Columbia, SC

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

Well, unfortunately, the new .dll and .exe didn't seem to work.
Attached is the log file.
Description: 12:05 attempt at FTPing a file.

Reply with quote

Advertisement

You can post new topics in this forum