CFDirectory is saying that it can't copy files to destination directory

1k Views Asked by At

We have a simple script that copies files across from a base install folder we created to house files for our application. When we choose to install a new site, based on these files, it's saying that the destination directory can't be found.

<cfset variables.destination = "#variables.base_path#\#variables.destination#\wwwroot\">
<!--- actually copying the base installation to the new location--->
<cfdirectory  action="copy" directory="#mycontent.directory#\#mycontent.name#" destination="#variables.destination#" recurse="yes" >
<!--- end copying the system files ---> 

The wwwroot directory will always exist on the system. We are trying to push files into that folder. However it's throwing an error and won't allow it to go through.

The actual error message being caught is:

The specified directory C:\home\domainname.com\wwwroot\ could not be created. The most likely cause of this error is that C:\home\domainname.com\wwwroot\ already exists on your file system.

1

There are 1 best solutions below

0
Simon Fermor On

I tried the following in ColdFusion 11:

<cfdirectory directory="//users/myname/sites/test/source"
    destination="//users/myname/sites/test/dest"
    action="copy" recurse="yes">

This works fine, whether the folder has been previously created or not. Also, it seems that the recurse attribute is supported, despite the documentation only stating that it is valid for list and delete actions.

https://wikidocs.adobe.com/wiki/display/coldfusionen/cfdirectory

As it seems to happen some times but not others perhaps it is a timing issue or with large files / multiple folders?