I have an interface that allows an authorized user to select
a directory from his/her profile and delete it.
The problem I have is that if the directory has subdirectories in it I can't delete it if it contains files. Also if the subdirectory contains additional subdirectories and so on.. I need to delete everything
below the selected directory. I 'think' I was on the correct track using the code below but my mind has wandered....
Thanks,
Dave
<CFDIRECTORY action="LIST" name="FilesToRemove" directory="#REQUEST.UploadLocation#\#ListGetAt (FORM.DirectoryID,1)#">
<CFOUTPUT QUERY="FilesToRemove">
<CFIF FilesToRemove.Type is "Dir">
<CFDIRECTORY action="LIST"
name="SubDirFilesToRemove"
directory="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#SubDirFilesToRemove.Name#">
<CFOUTPUT QUERY="SubDirFilesToRemove">
<CFIF Len(SubDirFilesToRemove.Name) GT 2>
<CFFILE action="DELETE"
file="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#SubDirFilesToRemove.Name#">
</CFIF>
</CFOUTPUT>
<CFDIRECTORY action="DELETE"
directory="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#SubDirFilesToRemove.Name#">
<CFELSEIF FilesToRemove.Type is "File">
<CFIF Len(FilesToRemove.Name) GT 2>
<CFFILE action="DELETE"
file="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#FilesToRemove.Name#">
</CFIF>
</CFIF>
</CFOUTPUT>
<CFDIRECTORY action="DELETE" directory="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#"
a directory from his/her profile and delete it.
The problem I have is that if the directory has subdirectories in it I can't delete it if it contains files. Also if the subdirectory contains additional subdirectories and so on.. I need to delete everything
below the selected directory. I 'think' I was on the correct track using the code below but my mind has wandered....
Thanks,
Dave
<CFDIRECTORY action="LIST" name="FilesToRemove" directory="#REQUEST.UploadLocation#\#ListGetAt (FORM.DirectoryID,1)#">
<CFOUTPUT QUERY="FilesToRemove">
<CFIF FilesToRemove.Type is "Dir">
<CFDIRECTORY action="LIST"
name="SubDirFilesToRemove"
directory="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#SubDirFilesToRemove.Name#">
<CFOUTPUT QUERY="SubDirFilesToRemove">
<CFIF Len(SubDirFilesToRemove.Name) GT 2>
<CFFILE action="DELETE"
file="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#SubDirFilesToRemove.Name#">
</CFIF>
</CFOUTPUT>
<CFDIRECTORY action="DELETE"
directory="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#SubDirFilesToRemove.Name#">
<CFELSEIF FilesToRemove.Type is "File">
<CFIF Len(FilesToRemove.Name) GT 2>
<CFFILE action="DELETE"
file="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#\#FilesToRemove.Name#">
</CFIF>
</CFIF>
</CFOUTPUT>
<CFDIRECTORY action="DELETE" directory="#REQUEST.UploadLocation#\#ListGetAt(FORM.DirectoryID,1)#"