How do I delete a folder and all files and subfolders beneath it?

The tag has a delete action, but this will throw an error if there is anything in the directory. To remove a directory and everything inside it, simply use the recurse attribute:

<cfset dir = "c:\temp">
<cfdirectory action="delete" directory="#dir#" recurse="true">

This question was written by Raymond Camden
It was last updated on April 6, 2006.

Categories

File and Directory Access

Comments

comments powered by Disqus