In coldFusion CFFTP, existsDir generates an error if dir does not exist

I use existsDirto check if a folder exists or not.

<cfftp action="existsDir" 
       connection="FTP" 
       directory="/Download/Test">
#cfftp.returnvalue#

If the folder exists, everything works fine. returnvalue- "Yes". If the folder does not exist, then the action existsDirends with the following error:

An error occurred during the sFTP existsDir operation. The system cannot find the path /Download/Test 

The whole point of this action is to determine if a folder exists. However, this causes an error if it does not exist. Did I miss something?

I can add try and catch around this whole statement (I will add it anyway to be safe), but that would make existDir it pointless.

+4
source share
1 answer

. , CF 2016 ( ). , stoponerror = "" cfftp action = "existsDir", :

<cfftp action="existsDir"
       connection="ftp_connection"
       directory="#remote_path#"
       stoponerror="No">

, , Dir;

<cfif cfftp.succeeded NEQ "YES">

    <!--- Create directory --->
    <cfftp action="createDir"
         connection="ftp_connection"
         directory="#remote_path#"
         stoponerror="No">
</cfif>
+1

All Articles