Issue - WinSCP. NET Assembly Product Version 5.0.6.0

Advertisement

j0se
Joined:
Posts:
8
Location:
Wrong Place - Wrong Time

Issue - WinSCP. NET Assembly Product Version 5.0.6.0

Dll information:
Assembly/File Version: 1.0.0.132
Product Version 5.0.6.0

Issue:
When attempting to execute the following code the WinSCP.exe shows the UI and generates the following C# project (Exception: "Timeout waiting for WinSCP to respond."). The ExecutablePath is pointing to the WinSCP.exe which came with the .dll that Martin posted. The code below is based on the code sample posted here (https://winscp.net/eng/docs/library#csharp)?

Also, it still generates a bug if setting the session.ExeExecutablePath and not the session.ExecutablePath. The ExeExecutablePath does not seem to mentioned in the document here (https://winscp.net/eng/docs/library_session).

Thank you for the effort to develop this and I'll assist however I can.

All the best.

        public bool SetFileViaSFTP(string fullFileName, string hostName, string remotePath, string userName, string password, string sshHostKey)
        {

            try
            {

                // Setup session options
                
                SessionOptions sessionOptions = new SessionOptions();
                sessionOptions.Protocol = Protocol.Sftp;
                sessionOptions.HostName = hostName;
                sessionOptions.UserName = userName;
                sessionOptions.Password = password;
                sessionOptions.SshHostKey = sshHostKey;
                
                using (Session session = new Session())
                {
                    // Connect
                    session.ExecutablePath = WebConfigurationManager.AppSettings["WinSCPExePath"] + "WinSCP.exe";
                    // session.ExeExecutablePath = WebConfigurationManager.AppSettings["WinSCPExePath"] + "WinSCP.exe";
                    session.Open(sessionOptions);

                    // Upload files
                    TransferOptions transferOptions = new TransferOptions();
                    transferOptions.TransferMode = TransferMode.Automatic;
                    
                    TransferOperationResult transferResult;
                    transferResult = session.PutFiles(fullFileName, remotePath, false, transferOptions);

                    // Throw on any error
                    transferResult.Check();

                    // Print results
                    foreach (TransferEventArgs transfer in transferResult.Transfers)
                    {
                        Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
                    }
                }

                Console.WriteLine("Success");

                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine("Failure: {0}", e);

                return false;
            }        
        }    

Reply with quote

j0se
Joined:
Posts:
8
Location:
Wrong Place - Wrong Time

Doh!!!!

This issue appears to have been related to a PEBKAC issue which has now been resolve through judicious application of electric shock therapy. Realized when checked that the download version posted here (https://winscp.net/eng/download.php) is the same Product Version but different Assembly/File Version (1.0.0.235). Please excuse the oversight and let it be known the offending party (me) has a written mark on his record as a lesson to check for the latest in the future.

Reply with quote

Advertisement

You can post new topics in this forum