SFTP Object
 
Syntax
 
SFTP.FileExists(remotePath As String, ByVal followLinks As Long) As Long
 
Description
Returns a value to indicate whether the remote file exists or not. remotePath is the path of the remote file. If followLinks is 1, then symbolic links will be followed on the server.
This method returns one of the following possible values:
  • -1: Unable to check. Examine the LastErrorText to determine the reason for failure.
  • 0: File does not exist.
  • 1: The regular file exists.
  • 2: It exists, but it is a directory.
  • 3: It exists, but it is a symlink (only possible if followLinks is 0)
  • 4: It exists, but it is a special filesystem entry type.
  • 5: It exists, but it is an unkown filesystem entry type.
  • 6: It exists, but it is an socket filesystem entry type.
  • 7: It exists, but it is an char device entry type.
  • 8: It exists, but it is an block device entry type.
  • 9: It exists, but it is an FIFO entry type.
Note: The values greater than zero correspond to the possible values as specified in the SFTP protocol specification. A given value may not make sense on all operating systems.
 
See Also

Example
Sub Main
 
' Connect to the SSH server. 
Dim hostname As String
hostname = "sftp.example.com"
Dim port As Long
port = 22
Dim success As Long
success = sftp.Connect(hostname,port)
If (success <> 1) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
' Authenticate with the SSH server.  Chilkat SFTP supports
' both password-based authenication as well as public-key
' authentication.  This example uses password authenication.
success = sftp.AuthenticatePw("myLogin","myPassword")
If (success <> 1) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
' After authenticating, the SFTP subsystem must be initialized:
success = sftp.InitializeSftp()
If (success <> 1) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
' Check to see if a file exists
 
' The return value is one of the following values:
' -1: Unable to check. Examine the LastErrorText to determine the reason for failure.
' 0: File does not exist.
' 1: The regular file exists.
' 2: It exists, but it is a directory.
' 3: It exists, but it is a symlink (only possible if followLinks is false)
' 4: It exists, but it is a special filesystem entry type.
' 5: It exists, but it is an unkown filesystem entry type.
' 6: It exists, but it is an socket filesystem entry type.
' 7: It exists, but it is an char device entry type.
' 8: It exists, but it is an block device entry type.
' 9: It exists, but it is an FIFO entry type.
 
Dim followLinks As Long
followLinks = 1
Dim status As Long
status = sftp.FileExists("someDir/someFile.txt",followLinks)
If (status < 0) Then
    Debug.Print sftp.LastErrorText
    Exit Sub
End If
 
Debug.Print "status = " & status
 
Debug.Print "Success"
 
End Sub