TScFTPClient: Implement a FileExists and a DirectoryExists function
Posted: 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
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