Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
...13 years later...
I like Mike's solution, but sometimes the directory functions are weird in that after you delete, then createa new one, it throws an error saying that hte directory already exists. Even after checking for existence.
FWIW, I'm using directoryExists(), directoryDelete(), and directoryCreate(), rather than <cfdirectory>.
Copy link to clipboard
Copied
Myka wrote:
... sometimes the directory functions are weird in that after you delete, then createa new one, it throws an error saying that hte directory already exists. Even after checking for existence.
Myka, there may be a good reason why it is impossible to "delete, then create" a directory or file within the same request. Namely, the thread to delete the directory or file may still be active when ColdFusion runs the function to create.
The usual solution is to use a named lock to separate the delete and create operations:
<cflock name="abc123">
<!--- delete operation --->
</cflock>
<cflock name="abc123">
<!--- create operation --->
</cflock>