Hi, I am in the process of moving my ColdFusion application over from a server using ColdFusion 5.0 to a different server using ColdFusion MX. So far, I have found the transition to be pretty painless. However, I did come across one glitch that I just can’t seem to figure out.
I have been using a custom tag called CF_DeleteDirectory to delete directories that may contain one or more files or subdirectories. On the ColdFusion 5.0 server I have never had a problem with my code but moving it to the MX server has created the following error message every time:
The specified Directory attribute F:\AcademyPAWebSite\eschool\courses\1836\1716 cannot be deleted.
This directory is not empty. This condition was encountered during a cfdirectory action="DELETE".
The error occurred in F:\AcademyPAWebsite\eschool\securePages\BUILDER\DeleteDirectory.cfm: line 53
51 :
52 : <!--- DELETE THE DIRECTORY --->
53 : <CFDIRECTORY ACTION="DELETE" DIRECTORY="#attributes.directory#">
54 : <CFSETTING ENABLECFOUTPUTONLY="No">
55 :
In this example, the directory I am trying to delete is labeled “1716” and it contains numerous files and subdirectories inside it.
I code I am using on my “deleteLesson.cfm” template is:
<CFMODULE
Template="DeleteDirectory.cfm"
directory="F:\AcademyPAWebSite\eschool\courses\#URL.CourseID#\#url.LessonID#">
The actual code of the custom tag (DeleteDirectory.cfm) is:
<!--- MAKE SURE THE DIRECTORY EXISTS --->
<CFIF NOT DirectoryExists(attributes.directory)>
<CFTHROW MESSAGE="The Directory (#attributes.directory#) Does Not Exist!">
</CFIF>
<!--- Kill any leading "\" in the directory --->
<CFIF right(attributes.directory,1) is "\">
<CFSET attributes.directory = left(attributes.directory,len(attributes.directory)- 1)>
</CFIF>
<!--- CHECK THE CONTENTS OF THE DIRECTORY --->
<CFDIRECTORY ACTION="LIST" DIRECTORY="#attributes.directory#" NAME="TheDir">
<!--- IF THE DIRECTORY IS NOT EMPTY, GO THROUGH AND EMPTY IT --->
<CFIF TheDir.Recordcount GT 2>
<CFLOOP QUERY="TheDir">
<CFIF Type is "File">
<CFFILE ACTION="DELETE" FILE="#attributes.directory#\#Name#">
<CFELSEIF Type is "Dir" and name is not "." and name is not "..">
<CF_DeleteDirectory DIRECTORY="#attributes.directory#\#Name#">
</CFIF>
</CFLOOP>
</CFIF>
<!--- DELETE THE DIRECTORY --->
<CFDIRECTORY ACTION="DELETE" DIRECTORY="#attributes.directory#">
<CFSETTING ENABLECFOUTPUTONLY="No">
<!---Copyright, 1999 Control Data Systems, Inc.
--->
I tested to make sure the url variables were indeed being passed correctly and they are, so I don’t think that is the problem.
If anyone can assist me with this problem I would really appreciate it!
Thanks,
Mike