Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
1.1k views
in .NET FTP by (160 points)
reopened by
Hello, We are running into an error "No Such File" error trying to upload files using SFTP. The file does NOT get uploaded. Below is my code and logs.

[code] 
                   {
                   SecureFTPConnection.LogLevel = EnterpriseDT.Util.Debug.LogLevel.All;
                    SecureFTPConnection.LogFile = @"C:\EdtPro\logs\log.txt"; 

                    SecureFTPConnection sftpConnection = new SecureFTPConnection();
                    sftpConnection.ServerAddress = host;
                    sftpConnection.UserName = _login;
                    sftpConnection.Password = _password;
                    sftpConnection.Protocol = FileTransferProtocol.SFTP;
                    sftpConnection.ServerValidation = SecureFTPServerValidationType.None;
                    sftpConnection.LicenseOwner = GetSftpLicenseOwner();
                    sftpConnection.LicenseKey = GetSftpLicenseKey();                    
                    
                    sftpConnection.Connect();

                    // Store the sftpConnection in the object that we pass into the
                    // asynchronous operations.
                    state.SftpConnection = sftpConnection;
                    state.Data = fileContents;

                    // Get the event to wait on.
                    waitObject = state.OperationComplete;
                    
                    sftpConnection.BeginUploadByteArray(fileContents, path, new AsyncCallback(EndBeginUploadByteArrayCallback), state);
                }
          } 

            [code]private static void EndBeginUploadByteArrayCallback(IAsyncResult ar)
        {
            FtpState state = (FtpState)ar.AsyncState;
            SecureFTPConnection sftpConnection = state.SftpConnection;
            try
            {
                sftpConnection.EndUploadByteArray(ar);
                state.StatusDescription = (sftpConnection.LastValidReply != null ? sftpConnection.LastValidReply.ReplyText :   string.Empty);
                sftpConnection.Close();
                // Signal the main application thread that 
                // the operation is complete.
                state.OperationComplete.Set();

                if (state.Helper.OperationCompleted != null)
                {
                    state.Helper.OperationCompleted(null, new OperationCompletedEventArgs(state.StatusDescription));

                }
            }
            catch (Exception e)
            {                
                state.OperationException = e;
                state.OperationComplete.Set();
                throw;
            }

                if (waitForComplete)
                    waitObject.WaitOne();

                if (state.OperationException != null)
                {
                    throw Logging.Logger.LogAndReturnFault(
                        new Contract.Fault.ConnectionFault(Contract.Fault.ConnectionFailureReason.OperationException,               state.OperationException.Message), baseRequest);
                }[/code][/code]


I tried using:
sftpConnection.ServerCompatibility = SecureFTPCompatibilityFlags.SSHDisableChmodAfterPut;

but that did not help either. We are using version edtFTPnetPRO version 7.3.1.20

Your help will be appreciated. Thanks

Here are the logs:

ALL [FTPConnectionPool] 5 Jun 2015 08:12:04.556 : Freed master connection 0 - 0
ALL [FTPTaskProcessor] 5 Jun 2015 08:12:04.560 : Exiting RunTask on connection 0
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.556 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Did not find license subkeys Software\Enterprise Distributed Technologies\edtFTPnet PRO or in registry
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Did not find license subkeys Software\Enterprise Distributed Technologies\edtFTPnet PRO or in registry
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Did not find license subkeys Software\Enterprise Distributed Technologies\edtFTPnet PRO or in registry
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Looking for subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO (fallback )
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Found license subkey Software\Enterprise Distributed Technologies\edtFTPnet PRO
DEBUG [LicenseProperties] 5 Jun 2015 08:12:04.560 : Did not find license subkeys Software\Enterprise Distributed Technologies\edtFTPnet PRO or in registry
INFO [LicenseProperties] 5 Jun 2015 08:12:04.560 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 5 Jun 2015 08:12:04.560 : Production license
DEBUG [FTPConnection] 5 Jun 2015 08:12:04.560 : Set LocalDirectory='c:\window

2 Answers

0 votes
by (162k points)
It looks like you are trying to open a file in the root directory, /test1.zip.txt. Normally you won't have permission to do this - are you sure this is the correct location?
0 votes
by (160 points)
Thanks for the prompt reply. Yeah you are right the path is actually as in cwd shown in the logs is /ADI/CGG and yes that's not the root directory. But I was thinking it would resolve it because it seems to recognize the cwd. After I pass in the path explicitly it seems to work. See the log below. When I run the edtFTPnetPRO tool, it is able to resolve and upload without specifying the path explicitly. What do you think may be the reason? Again thanks in advance.

DEBUG [FTPTaskProcessor] 5 Jun 2015 11:41:15.243 : Running task on connection 6: [ID=7] DeleteFile(String="/ADI/CGG/test1.zip.txt")
DEBUG [SSHFTPClient] 5 Jun 2015 11:41:15.243 : ResolveRemotePath('/ADI/CGG/test1.zip.txt'); [cwd='/ADI/CGG']
DEBUG [SSHFTPClient] 5 Jun 2015 11:41:15.243 : Resolved to '/ADI/CGG/test1.zip.txt'
DEBUG [SFTPSubsystem] 5 Jun 2015 11:41:15.244 : GetAttributes(/ADI/CGG/test1.zip.txt)

Categories

...