Archived Forum Post

Index of archived forum posts

Question:

FTP downloading - indication of completion

Aug 05 '17 at 13:07

Hello, I recently replaced the original programmer who used Chilkat to process FTP requests.

Their code, which was copied verbatim from the website, was slightly altered as follows:

success = sftp.DownloadFileByName(remoteFilePath, localFilePath)
If (success <> True) Then Throw New System.Exception(sftp.LastErrorText)

If File.Exists(localFilePath) Then File.Copy(localFilePath, archiveFilePath, True)

success = sftp.RemoveFile(absPath & "/" & fileObj.Filename)
If (success <> True) Then Throw New System.Exception(sftp.LastErrorText)

On July 17th, we received a call from an upset customer who wanted to know why their file wasn't processed. Upon investigation. it looks as though the file was removed from the FTP without a local copy present.

In addition, I received two of the following error messages:

    ChilkatLog:
  RemoveFile:
    DllDate: Mar 20 2017
    ChilkatVersion: 9.5.0.66
    UnlockPrefix: [removed by me]
    Architecture: Little Endian; 32-bit
    Language: .NET 4.0
    VerboseLogging: 0
    SshVersion: SSH-2.0-CerberusFTPServer_8.0 FIPS
    SftpVersion: 3
    removeFile:
      remotePath: [removed by me]
      StatusResponseFromServer:
        Request: FXP_REMOVE
        InformationReceivedFromServer:
          StatusCode: 22
          StatusMessage: 
        --InformationReceivedFromServer
      --StatusResponseFromServer
    --removeFile
    Failed.
  --RemoveFile
--ChilkatLog

We have full read/write/delete rights on the FTP server. I added the exception handling (which was previously the "console.writeline" as was in the code example) and these messages are quite frequent now.

QUESTION: the line "sftp.DownloadFileByName" - is the success check that follows a COMPLETION of the download file or that it is downloading the file?

I need to know quickly because apparently, this wasn't the first time. The programmer used the Chilkat code example verbatim, and this why no one noticed before.

The documentation is... too sparse to make a determination.

Thanks for the help.


Answer

When DownloadFileByName returns true, the file is completely downloaded to your local path. There are "....Async" methods that return when the download is initiated, but you are not using them.