我正在使用existsDir检查文件夹是否存在。
<cfftp action="existsDir"
connection="FTP"
directory="/Download/Test">
#cfftp.returnvalue#如果文件夹存在,则一切正常。returnvalue是“是”。如果该文件夹不存在,则existsDir操作将失败,并显示以下错误:
An error occurred during the sFTP existsDir operation. The system cannot find the path /Download/Test 此操作的全部目的是确定文件夹是否存在。然而,如果它不存在,它就会导致错误。我是不是遗漏了什么?
我可以在整个语句中添加try和catch (为了安全起见,我无论如何都要添加它),但这会使这个existDir变得毫无意义。
发布于 2016-12-07 21:57:27
我也经历过这种情况。即使在CF 2016 (我们刚刚迁移到它)中似乎也是一个bug。我通过在cfftp action="existsDir“使用过程中将stoponerror=设置为”No“来解决这个问题;
<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>https://stackoverflow.com/questions/25872961
复制相似问题