You have to manually go through and delete all the files and directories
within it first. big pain, especially if you have nested directories.
However, recursive CFFUNCTION calls makes it much easier.
Here's some code. won't work as advertised, but it should get you started.
I've intentionally not included the delete statements, rather outputing what
would happen for safety's sake ;)
<cffunction name="deleteDir">
<cfargument name="dir" type="string" required="true" hint="full path of
directory to delete" />
<cfdirectory action="list"
directory="#dir#"
name="files" />
<cfloop query="files">
<cfif type EQ "dir" AND name NEQ "." AND name NEQ "..">
<cfset deleteDir("#dir#/#name") />
<cfelseif type EQ "file">
<cfoutput>delete file #dir#/#name#<br /></cfoutput>
</cfif>
</cfloop>
<cfoutput>delete dir #dir#/#name#</cfoutput>
</cffunction>
HTH,
barneyb
---
Barney Boisvert, Senior Development Engineer
AudienceCentral
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax : 360.647.5351
www.audiencecentral.com
> -----Original Message-----
> From: Matthew Friedman [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 22, 2003 12:21 PM
> To: CF-Talk
> Subject: Deleting an entire folder
>
>
> I need to have CF delete an entire folder and all files and folders in the
> Structure on the web server.
>
> How would I do this, I tried with <cfdirectory> and it would not let me.
>
> Matthew
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics.
http://www.fusionauthority.com/signup.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4