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 No such file or directory

tzpow2 wrote:

Hi the log is in the very first post.

That's a log with ToUpper, hence useless.

I am using version 5.7.6, and I can't upgrade it because the server that is running the Jobs is also the same version.

You should not rely on an installed version of WinSCP. Your application should deploy it's own copy of WinSCP binaries.
See https://winscp.net/eng/docs/library_install#installing
tzpow2

Re: Can't get attributes of file No such file or directory

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.



Hi the log is in the very first post. I am using version 5.7.6, and I can't upgrade it because the server that is running the Jobs is also the same version.

Thanks
martin

Re: Can't get attributes of file No such file or directory

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.
tzpow2

Re: Can't get attributes of file No such file or directory

No one?
Guest

Re: Can't get attributes of file No such file or directory

martin wrote:

This might be the problem:
thisfile = thisfile.ToUpper();
Use the file name as is, when calling session.GetFiles.


No, I tried removing that still getting the same error.
martin

Re: Can't get attributes of file No such file or directory

This might be the problem:
thisfile = thisfile.ToUpper();
Use the file name as is, when calling session.GetFiles.
tzpow2

Can't get attributes of file No such file or directory

Hi
I am using C# code to download a file from FTP server and I am getting the "Can't get attributes of file No such file or directory" error. But there is the file. I can download it using GUI. It is very strange, if the test file is in "ROOT" directory, it works, but not in the sub folder. Also the folder looks strange. It is like "Jade:/PROD/Outbound". Anyone have this issue before?

Here is my code.
  string winscpPath = "C:\\Program Files (x86)\\WinSCP\\WinSCP.exe";

            string username = "username";
            string password = "abc123";
            string ftpSite = "SFTP.abc123.com";
            string localPath = @"\\191.26.25.22\JADE\DownloadFiles\";
           // string remoteFTPDirectory = "/"; //****Works if test file in root****
            string remoteFTPDirectory = "/PROD/Outbound";
            string sshKey = "ssh-dss 1024 2e:e0:68:f0:a0:40:12s3d1f2123s1dfsdf";
            Boolean winSCPLog = true;
            string winSCPLogPath = @"\\191.26.25.22\JADE\";

            SessionOptions sessionOptions = new SessionOptions
            {
                //FtpSecure = FtpSecure.Implicit,
                //FtpMode = FtpMode.Active,
                //Timeout = new TimeSpan(0, 0, 120), //120 seconds
                Protocol = Protocol.Sftp,
                HostName = ftpSite,
                UserName = username,
                Password = password,
                PortNumber = 22,
                SshHostKeyFingerprint = sshKey


                // SshHostKeyFingerprint = sshKey for ssh
            };

            try
            {
                using (Session session = new Session())
                {
                    // WinSCP .NET assembly must be in GAC to be used with SSIS,
                    // set path to WinSCP.exe explicitly, if using non-default path.
                    session.ExecutablePath = winscpPath;
                    session.DisableVersionCheck = true;


                    if (winSCPLog)
                    {
                        session.SessionLogPath = @winSCPLogPath + @"ftpLog.txt";
                        session.DebugLogPath = @winSCPLogPath + @"Ftpdebuglog.txt";
                    }

                    session.Open(sessionOptions);


                    RemoteDirectoryInfo rDirectory = session.ListDirectory(remoteFTPDirectory);

                    string filename = "";
                    for (int i = 0; i < rDirectory.Files.Count; i++)
                    {
                        string thisfile;
                        thisfile = rDirectory.Files[i].Name;
                        thisfile = thisfile.ToUpper();

                        if (thisfile.Contains("TEST") == true)
                        {
                            // session.MoveFile(remoteFTPDirectory + "/" + thisfile, remoteFTPDirectory + "/" + thisfile + ".txt");
                            session.GetFiles(thisfile, localPath, true);
                            filename = filename + thisfile + "\n";
                        }

                    }
                    session.Close();

                }
            }
            finally
            {
            }