Cheking file exist

Top  Previous 

Checking if a file exists on the SFTP server.

 

[C#]

bool ExistsFile(string filename) {

 try {

         this.sftp.GetFileSize( filename );

         return true;

 } catch( SftpException ) {

         return false;

 }

}

 

[Visual Basic]

Function ExistsFile(ByVal filename As String) As Boolean

 Try

         Me.sftp.GetFileSize( filename )

         Return True

 Catch ex As SftpException

         Return False

 End Try

End Function