TScFTPClient: Implement a FileExists and a DirectoryExists function

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
mmkw
Posts: 4
Joined: Tue 17 Jul 2018 10:34

TScFTPClient: Implement a FileExists and a DirectoryExists function

Post by mmkw » Tue 17 Jul 2018 10:53

Hi there,
I just downloaded the trial of the newest SecureBridge version.
I need a possibility to test, if a file and/or a directory exists already on the remote server.

Normally there are 2 ways to get this done:

1.) Get the ContentList of the current path and check if the file or directory is in it. This solution works with TScFTPClient. But the List can get very big when there are many files, so this solution is not optimal.

2.) Try to change to a remote directory with changeDir and check the result code. If it is 550, the directory does not exist (The same wit FileExists with getting header info of the file). Unfortunately, TScFTPClient throws an exception, saying that the path does not exist. Of course I could enclose that kind of check with try..except, to handle the exception. That would work good when runnig outside the IDE, but inside I would get so much frustrating Exceptions. I do not like to "ignore" all those exceptions in each of my projects, so I am wondering, if there is a possibilty to prevent the TScFTPClient from throwing that exception (maybe a property FTPResultExceptions: Boolean) or if there is another possibility to get the desired information.

best regards

Kai

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: TScFTPClient: Implement a FileExists and a DirectoryExists function

Post by ViktorV » Wed 18 Jul 2018 12:56

If you want us to add this functionality, please write about it at our User Voice forum: https://devart.uservoice.com/forums/174370-securebridge. If your suggestion gets enough votes, we will consider the possibility of its implementation.
Note, you can use the TScSFTPClient.CheckFile method to check if a file (or its part) that client already has matches the one that is on the server: https://www.devart.com/sbridge/docs/ind ... ckfile.htm

Post Reply