gpt4 book ai didi

coldfusion - 在 ColdFusion CFFTP 中,如果目录不存在,则existsDir 会生成错误

转载 作者:行者123 更新时间:2023-12-04 21:15:04 28 4
gpt4 key购买 nike

我正在使用 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(为了安全起见,无论如何我都会添加它),但这会使这个existsDir 毫无意义。

最佳答案

我也经历过这个。即使在 CF 2016(我们刚刚迁移到)中,这似乎也是一个错误。我通过在 cfftp action="existsDir"使用过程中设置 stoponerror="No"来解决这个问题;

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

然后,您可以检查它是否“成功”并在必要时创建目录;
<cfif cfftp.succeeded NEQ "YES">

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

关于coldfusion - 在 ColdFusion CFFTP 中,如果目录不存在,则existsDir 会生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25872961/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com